diff --git a/consul/state_store.go b/consul/state_store.go index 2620737e42..6a90af3b41 100644 --- a/consul/state_store.go +++ b/consul/state_store.go @@ -296,6 +296,12 @@ func (s *StateStore) initialize() error { Unique: true, Fields: []string{"Key"}, }, + "id_prefix": &MDBIndex{ + Virtual: true, + RealIndex: "id", + Fields: []string{"Key"}, + IdxFunc: DefaultIndexPrefixFunc, + }, }, Decoder: func(buf []byte) interface{} { out := new(structs.DirEntry) diff --git a/consul/state_store_test.go b/consul/state_store_test.go index 621734ef3a..0e5781ce39 100644 --- a/consul/state_store_test.go +++ b/consul/state_store_test.go @@ -1444,6 +1444,15 @@ func TestKVSDelete(t *testing.T) { t.Fatalf("bad: %v", d) } + // Check tombstone exists + _, res, err := store.tombstoneTable.Get("id", "/foo") + if err != nil { + t.Fatalf("err: %v", err) + } + if res == nil || res[0].(*structs.DirEntry).ModifyIndex != 1020 { + t.Fatalf("bad: %#v", d) + } + // Check that we get a delete select { case idx := <-gc.ExpireCh(): @@ -1801,6 +1810,20 @@ func TestKVSDeleteTree(t *testing.T) { t.Fatalf("bad: %v", ents) } + // Check tombstones exists + _, res, err := store.tombstoneTable.Get("id_prefix", "/web") + if err != nil { + t.Fatalf("err: %v", err) + } + if len(res) != 3 { + t.Fatalf("bad: %#v", d) + } + for _, r := range res { + if r.(*structs.DirEntry).ModifyIndex != 1010 { + t.Fatalf("bad: %#v", r) + } + } + // Check that we get a delete select { case idx := <-gc.ExpireCh():