From 96ea0001c27bd74def84e4a14539308836ce6887 Mon Sep 17 00:00:00 2001 From: aman bansal Date: Tue, 5 Jan 2021 18:04:09 +0530 Subject: [PATCH] fixing unique proposal key error (#7218) --- dgraph/cmd/zero/raft.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dgraph/cmd/zero/raft.go b/dgraph/cmd/zero/raft.go index bd22e0c554b..50cd829d2e9 100644 --- a/dgraph/cmd/zero/raft.go +++ b/dgraph/cmd/zero/raft.go @@ -119,7 +119,12 @@ func (n *node) proposeAndWait(ctx context.Context, proposal *pb.ZeroProposal) er Ctx: cctx, } key := n.uniqueKey() - x.AssertTruef(n.Proposals.Store(key, pctx), "Found existing proposal with key: [%v]", key) + // unique key is randomly generated key and could have collision. + // This is to ensure that even if collision occurs, we retry. + for !n.Proposals.Store(key, pctx) { + glog.Warningf("Found existing proposal with key: [%v]", key) + key = n.uniqueKey() + } defer n.Proposals.Delete(key) span.Annotatef(nil, "Proposing with key: %d. Timeout: %v", key, timeout)