-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of major points, but those can be worked out in a separate PR
ppi, err := m.sealer.AddPiece(sectorstorage.WithPriority(ctx, DealSectorPriority), m.minerSector(sid), m.unsealedInfos[sid].pieceSizes, size, r) | ||
if err != nil { | ||
return 0, 0, xerrors.Errorf("writing piece: %w", err) | ||
} | ||
|
||
err = m.addPiece(sid, Piece{ | ||
Piece: ppi, | ||
DealInfo: &d, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels potentially racy, We really should address that somehow - for example by:
- adding a
map[DealID]struct{r io.Reader; done chan struct{}}
to theSealing
struct (done channel can also be used for signalling errors) - here, registering a reader for that dealID, sending addpiece event, and waiting for the done channel
- Call sealer.AddPiece in the state handler for WaitDeals
} | ||
|
||
offset := m.unsealedInfos[sid].stored | ||
ppi, err := m.sealer.AddPiece(sectorstorage.WithPriority(ctx, DealSectorPriority), m.minerSector(sid), m.unsealedInfos[sid].pieceSizes, size, r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we need to take into account that this call will inevitably fail in a bunch of annoying ways (reader closed, process killed, etc.), and we need to have a way to make sure that we keep the sector in a sealable state.
I think that after we move this call into a state handler, we should be able to add some more states to basically journal what happens to a sector, and call a method on the storage to remove any data from the unsealed sector file if we suspect there can be some - like https://github.com/filecoin-project/specs-storage/blob/master/storage/storage.go#L55, but actually removing the data
For filecoin-project/lotus#2043
List of TODO improvements: https://github.com/filecoin-project/storage-fsm/issues/37