Browse Source

consul: Fixing blocking query if set table is at index 0

pull/17/head
Armon Dadgar 11 years ago
parent
commit
8f2ef0d7d2
  1. 16
      consul/kvs_endpoint.go

16
consul/kvs_endpoint.go

@ -58,7 +58,13 @@ func (k *KVS) Get(args *structs.KeyRequest, reply *structs.IndexedDirEntries) er
return 0, err
}
if ent == nil {
reply.Index = index
// Must provide non-zero index to prevent blocking
// Index 1 is impossible anyways (due to Raft internals)
if index == 0 {
reply.Index = 1
} else {
reply.Index = index
}
reply.Entries = nil
} else {
reply.Index = ent.ModifyIndex
@ -84,7 +90,13 @@ func (k *KVS) List(args *structs.KeyRequest, reply *structs.IndexedDirEntries) e
return 0, err
}
if len(ent) == 0 {
reply.Index = index
// Must provide non-zero index to prevent blocking
// Index 1 is impossible anyways (due to Raft internals)
if index == 0 {
reply.Index = 1
} else {
reply.Index = index
}
reply.Entries = nil
} else {
// Determine the maximum affected index

Loading…
Cancel
Save