should use Lock when mutating the flag

This commit is contained in:
zhiqiangxu 2024-01-05 23:49:19 +08:00
parent 930c946388
commit dfe484d6a2

View file

@ -166,13 +166,13 @@ func (mv *MVHashMap) MarkEstimate(k Key, txIdx int) {
panic(fmt.Errorf("path must already exist")) panic(fmt.Errorf("path must already exist"))
}) })
cells.rw.RLock() cells.rw.Lock()
if ci, ok := cells.tm.Get(txIdx); !ok { if ci, ok := cells.tm.Get(txIdx); !ok {
panic(fmt.Sprintf("should not happen - cell should be present for path. TxIdx: %v, path, %x, cells keys: %v", txIdx, k, cells.tm.Keys())) panic(fmt.Sprintf("should not happen - cell should be present for path. TxIdx: %v, path, %x, cells keys: %v", txIdx, k, cells.tm.Keys()))
} else { } else {
ci.(*WriteCell).flag = FlagEstimate ci.(*WriteCell).flag = FlagEstimate
} }
cells.rw.RUnlock() cells.rw.Unlock()
} }
func (mv *MVHashMap) Delete(k Key, txIdx int) { func (mv *MVHashMap) Delete(k Key, txIdx int) {