Fix AtomicPut panic if previous KVPair is not nil and key not exists in boltdb
Signed-off-by: Chun Chen <ramichen@tencent.com>
This commit is contained in:
parent
79b8613c95
commit
1f9cf17713
1 changed files with 3 additions and 0 deletions
|
@ -257,6 +257,9 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt
|
|||
return store.ErrKeyModified
|
||||
}
|
||||
if previous != nil {
|
||||
if len(val) == 0 {
|
||||
return store.ErrKeyNotFound
|
||||
}
|
||||
dbIndex = binary.LittleEndian.Uint64(val[:libkvmetadatalen])
|
||||
if dbIndex != previous.LastIndex {
|
||||
return store.ErrKeyModified
|
||||
|
|
Loading…
Add table
Reference in a new issue