Skip to content

Commit

Permalink
fix: eviction locking
Browse files Browse the repository at this point in the history
  • Loading branch information
nugaon committed Nov 4, 2024
1 parent 691a43d commit 7432ed3
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/storer/internal/reserve/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ func (r *Reserve) Put(ctx context.Context, chunk swarm.Chunk) error {
chunkType := storage.ChunkType(chunk)

// batchID lock, Put vs Eviction
lockId := lockId(chunk.Stamp())
r.multx.Lock(lockId)
defer r.multx.Unlock(lockId)
r.multx.Lock(string(chunk.Stamp().BatchID()))
defer r.multx.Unlock(string(chunk.Stamp().BatchID()))

stampHash, err := chunk.Stamp().Hash()
if err != nil {
Expand Down Expand Up @@ -659,7 +658,3 @@ func (r *Reserve) IncBinID(store storage.IndexStore, bin uint8) (uint64, error)

return item.BinID, store.Put(item)
}

func lockId(stamp swarm.Stamp) string {
return fmt.Sprintf("%x-%x", stamp.BatchID(), stamp.Index())
}

0 comments on commit 7432ed3

Please sign in to comment.