Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit 02f3bb3

Browse files
committed
Only one hash computation at a time
1 parent e40d44f commit 02f3bb3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

ss/pebbledb/db.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ type Database struct {
7373
// Cache for last range hashed
7474
lastRangeHashedCache int64
7575
lastRangeHashedMu sync.RWMutex
76+
hashComputationMu sync.Mutex
7677
}
7778

7879
type VersionedChangesets struct {
@@ -396,6 +397,12 @@ func (db *Database) ApplyChangesetAsync(version int64, changesets []*proto.Named
396397

397398
if db.config.HashRange > 0 {
398399
go func(ver int64) {
400+
// Try to acquire lock, return immediately if already locked
401+
if !db.hashComputationMu.TryLock() {
402+
return
403+
}
404+
defer db.hashComputationMu.Unlock()
405+
399406
if err := db.computeMissingRanges(ver); err != nil {
400407
fmt.Printf("maybeComputeMissingRanges error: %v\n", err)
401408
}

0 commit comments

Comments
 (0)