Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable on-the-fly-reindexing #1903

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion itests/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ func (f *TestFramework) Start(opts ...ConfigOpt) error {
cfg.Dealmaking.MaxStagingDealsBytes = 4000000 // 4 MB
}

cfg.Dealmaking.StartEpochSealingBuffer = 50

if f.config.StartEpochSealingBuffer > 0 {
cfg.Dealmaking.StartEpochSealingBuffer = f.config.StartEpochSealingBuffer
}
Expand Down Expand Up @@ -633,7 +635,7 @@ func (f *TestFramework) MakeDummyDeal(dealUuid uuid.UUID, carFilepath string, ro
if err != nil {
return nil, fmt.Errorf("getting chain head: %w", err)
}
startEpoch := head.Height() + abi.ChainEpoch(2000)
startEpoch := head.Height() + abi.ChainEpoch(600)
l, err := market.NewLabelFromString(rootCid.String())
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion lib/pdcleaner/pdcleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ func (p *pdcleaner) CleanOnce(ctx context.Context) error {
if err != nil {
return fmt.Errorf("checking if bitfield is set: %w", err)
}
if !present {
// If not present and start epoch has already passed (to cover any unproven sector in actor state)
if !present && deal.ClientDealProposal.Proposal.StartEpoch < head.Height() {
err = p.pd.RemoveDealForPiece(ctx, deal.ClientDealProposal.Proposal.PieceCID, deal.DealUuid.String())
if err != nil {
// Don't return if cleaning up a deal results in error. Try them all.
Expand Down
16 changes: 15 additions & 1 deletion piecedirectory/piecedirectory.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,21 @@ func (ps *PieceDirectory) BlockstoreGetSize(ctx context.Context, c cid.Cid) (int
return int(offsetSize.Size), nil
}

merr = multierror.Append(merr, fmt.Errorf("piece %s is not indexed correctly", p))
// The index is incomplete, so re-build the index on the fly
err = ps.BuildIndexForPiece(ctx, p)
if err != nil {
merr = multierror.Append(merr, fmt.Errorf("re-building index for piece %s: %w", p, err))
continue
}

// Now get the size again
offsetSize, err = ps.GetOffsetSize(ctx, p, c.Hash())
if err != nil {
merr = multierror.Append(merr, fmt.Errorf("getting size of cid %s in piece %s: %w", c, p, err))
continue
}

return int(offsetSize.Size), nil

}

Expand Down
2 changes: 0 additions & 2 deletions piecedirectory/piecedirectory_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ func testImportedIndex(ctx context.Context, t *testing.T, cl *client.Store) {
// directory should re-build the index and then return the size.
pm := NewPieceDirectory(cl, pr, 1)
pm.Start(ctx)
err = pm.BuildIndexForPiece(ctx, pieceCid)
require.NoError(t, err)
sz, err := pm.BlockstoreGetSize(ctx, rec.Cid)
require.NoError(t, err)
require.Equal(t, len(blk.RawData()), sz)
Expand Down
Loading