Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Pack multiple deals into a sector #38

Merged
merged 9 commits into from
Jun 26, 2020
Merged

Pack multiple deals into a sector #38

merged 9 commits into from
Jun 26, 2020

Conversation

arajasek
Copy link
Contributor

@arajasek arajasek added the enhancement New feature or request label Jun 25, 2020
@arajasek arajasek self-assigned this Jun 25, 2020
Copy link
Collaborator

@magik6k magik6k left a 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

Comment on lines +112 to +120
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,
})
Copy link
Collaborator

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 the Sealing 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)
Copy link
Collaborator

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

@magik6k magik6k changed the base branch from master to next June 26, 2020 11:02
@magik6k magik6k merged commit c059934 into next Jun 26, 2020
@magik6k magik6k deleted the asr/multiple-deals branch June 26, 2020 11:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants