Skip to content

Commit

Permalink
fix: revert chain sync mutex to a regular lock
Browse files Browse the repository at this point in the history
Conditions always call "unlock" so we can't safely use the condition
with both the read and write side of lock. So we might as well revert
back to a regular lock.

fixes #10616
  • Loading branch information
Stebalien committed Apr 4, 2023
1 parent 7a4082c commit 68f402d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ type SplitStore struct {
cancel func()

outOfSync int32 // for fast checking
chainSyncMx sync.RWMutex
chainSyncMx sync.Mutex
chainSyncCond sync.Cond
chainSyncFinished bool // protected by chainSyncMx

Expand Down
4 changes: 2 additions & 2 deletions blockstore/splitstore/splitstore_compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,8 @@ func (s *SplitStore) waitForSync() {
if atomic.LoadInt32(&s.outOfSync) == 0 {
return
}
s.chainSyncMx.RLock()
defer s.chainSyncMx.RUnlock()
s.chainSyncMx.Lock()
defer s.chainSyncMx.Unlock()

for !s.chainSyncFinished {
s.chainSyncCond.Wait()
Expand Down

0 comments on commit 68f402d

Please sign in to comment.