Skip to content

Commit

Permalink
fix(reserve): force overwrite index on collion (#4559)
Browse files Browse the repository at this point in the history
  • Loading branch information
istae authored Jan 30, 2024
1 parent bf56d82 commit 36855af
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ func (p *putterSessionWrapper) Done(ref swarm.Address) error {
}

func (p *putterSessionWrapper) Cleanup() error {
return errors.Join(p.PutterSession.Cleanup(), p.save())
return p.PutterSession.Cleanup()
}

func (s *Service) getStamper(batchID []byte) (postage.Stamper, func() error, error) {
Expand Down
1 change: 0 additions & 1 deletion pkg/api/stewardship.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func (s *Service) stewardshipPutHandler(w http.ResponseWriter, r *http.Request)

err = s.steward.Reupload(r.Context(), paths.Address, stamper)
if err != nil {
err = errors.Join(err, save())
logger.Debug("re-upload failed", "chunk_address", paths.Address, "error", err)
logger.Error(nil, "re-upload failed")
jsonhttp.InternalServerError(w, "re-upload failed")
Expand Down
1 change: 1 addition & 0 deletions pkg/statestore/storeadapter/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func allSteps() migration.Steps {
4: deletePrefix("blocklist"),
5: deletePrefix("batchstore"),
6: deletePrefix("sync_interval"),
7: deletePrefix("sync_interval"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/storageincentives/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var testData []byte

// Test asserts that MakeInclusionProofs will generate the same
// output for given sample.
func TestMakeInclusionProofsRegression(t *testing.T) {
func TestMakeInclusionProofsRegression_FLAKY(t *testing.T) {
t.Parallel()

const sampleSize = 16
Expand Down
14 changes: 4 additions & 10 deletions pkg/storer/internal/reserve/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,11 @@ func (r *Reserve) Put(ctx context.Context, store internal.Storage, chunk swarm.C

newStampIndex := true

switch item, loaded, err := stampindex.LoadOrStore(
indexStore,
storeBatch,
reserveNamespace,
chunk,
); {
case err != nil:
item, loaded, err := stampindex.LoadOrStore(indexStore, storeBatch, reserveNamespace, chunk)
if err != nil {
return false, fmt.Errorf("load or store stamp index for chunk %v has fail: %w", chunk, err)
case loaded && item.ChunkIsImmutable:
return false, fmt.Errorf("batch %s index %s: %w", hex.EncodeToString(chunk.Stamp().BatchID()), hex.EncodeToString(chunk.Stamp().Index()), storage.ErrOverwriteOfImmutableBatch)
case loaded && !item.ChunkIsImmutable:
}
if loaded {
prev := binary.BigEndian.Uint64(item.StampTimestamp)
curr := binary.BigEndian.Uint64(chunk.Stamp().Timestamp())
if prev >= curr {
Expand Down

0 comments on commit 36855af

Please sign in to comment.