Skip to content

Commit

Permalink
server/storage/mvcc: deflake TestHashKVWhenCompacting
Browse files Browse the repository at this point in the history
The HashByRev-goroutines exit since receive `donec` notification. The
Check-computed-hashes goroutine could not have chance to get the hash
result and be stuck forever. We should add case for donec when we wait
for hash result.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
  • Loading branch information
fuweid committed Sep 6, 2023
1 parent ea9ef76 commit a6f7bbe
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions server/storage/mvcc/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,18 +591,17 @@ func TestHashKVWhenCompacting(t *testing.T) {
defer wg.Done()
revHash := make(map[int64]uint32)
for {
r := <-hashCompactc
if revHash[r.compactRev] == 0 {
revHash[r.compactRev] = r.hash
}
if r.hash != revHash[r.compactRev] {
t.Errorf("Hashes differ (current %v) != (saved %v)", r.hash, revHash[r.compactRev])
}

select {
case r := <-hashCompactc:
if revHash[r.compactRev] == 0 {
revHash[r.compactRev] = r.hash
}

if r.hash != revHash[r.compactRev] {
t.Errorf("Hashes differ (current %v) != (saved %v)", r.hash, revHash[r.compactRev])
}
case <-donec:
return
default:
}
}
}()
Expand Down

0 comments on commit a6f7bbe

Please sign in to comment.