mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
storage: return error when tombstone on new generation
It is not allowed to put tombstone on an empty generation.
This commit is contained in:
parent
ffa87f9678
commit
ad8a291dc1
@ -115,8 +115,7 @@ func (ti *treeIndex) Tombstone(key []byte, rev revision) error {
|
||||
}
|
||||
|
||||
ki := item.(*keyIndex)
|
||||
ki.tombstone(rev.main, rev.sub)
|
||||
return nil
|
||||
return ki.tombstone(rev.main, rev.sub)
|
||||
}
|
||||
|
||||
func (ti *treeIndex) Compact(rev int64) map[revision]struct{} {
|
||||
|
@ -90,12 +90,17 @@ func (ki *keyIndex) restore(created, modified revision, ver int64) {
|
||||
|
||||
// tombstone puts a revision, pointing to a tombstone, to the keyIndex.
|
||||
// It also creates a new empty generation in the keyIndex.
|
||||
func (ki *keyIndex) tombstone(main int64, sub int64) {
|
||||
// It returns ErrRevisionNotFound when tombstone on an empty generation.
|
||||
func (ki *keyIndex) tombstone(main int64, sub int64) error {
|
||||
if ki.isEmpty() {
|
||||
log.Panicf("store.keyindex: unexpected tombstone on empty keyIndex %s", string(ki.key))
|
||||
}
|
||||
if ki.generations[len(ki.generations)-1].isEmpty() {
|
||||
return ErrRevisionNotFound
|
||||
}
|
||||
ki.put(main, sub)
|
||||
ki.generations = append(ki.generations, generation{})
|
||||
return nil
|
||||
}
|
||||
|
||||
// get gets the modified, created revision and version of the key that satisfies the given atRev.
|
||||
|
Loading…
x
Reference in New Issue
Block a user