mirror of https://github.com/status-im/consul.git
Don't insert tombstone for empty prefix delete. Other minor unit test fixes
This commit is contained in:
parent
fee418d378
commit
4498814843
|
@ -426,12 +426,14 @@ func (s *Store) kvsDeleteTreeTxn(tx *memdb.Txn, idx uint64, prefix string) error
|
||||||
deleted, err := tx.DeletePrefix("kvs", "id_prefix", prefix)
|
deleted, err := tx.DeletePrefix("kvs", "id_prefix", prefix)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed recursive deleting kvs entry: %s", err)
|
return fmt.Errorf("failed recursive deleting kvs entry: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if deleted {
|
if deleted {
|
||||||
if err := s.kvsGraveyard.InsertTxn(tx, prefix, idx); err != nil {
|
if prefix != "" { // don't insert a tombstone if the entire tree is deleted, all watchers on keys will see the max_index of the tree
|
||||||
return fmt.Errorf("failed adding to graveyard: %s", err)
|
if err := s.kvsGraveyard.InsertTxn(tx, prefix, idx); err != nil {
|
||||||
|
return fmt.Errorf("failed adding to graveyard: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := tx.Insert("index", &IndexEntry{"kvs", idx}); err != nil {
|
if err := tx.Insert("index", &IndexEntry{"kvs", idx}); err != nil {
|
||||||
return fmt.Errorf("failed updating index: %s", err)
|
return fmt.Errorf("failed updating index: %s", err)
|
||||||
|
|
|
@ -698,7 +698,7 @@ func TestStateStore_Txn_KVS_RO_Safety(t *testing.T) {
|
||||||
expected := []string{
|
expected := []string{
|
||||||
"cannot insert in read-only transaction",
|
"cannot insert in read-only transaction",
|
||||||
"cannot insert in read-only transaction",
|
"cannot insert in read-only transaction",
|
||||||
"cannot insert in read-only transaction",
|
"failed recursive deleting kvs entry",
|
||||||
}
|
}
|
||||||
if len(errors) != len(expected) {
|
if len(errors) != len(expected) {
|
||||||
t.Fatalf("bad len: %d != %d", len(errors), len(expected))
|
t.Fatalf("bad len: %d != %d", len(errors), len(expected))
|
||||||
|
|
Loading…
Reference in New Issue