From 00e94694a52ec4381649a0ed0bc9bba0cbd97aa6 Mon Sep 17 00:00:00 2001 From: aman-bansal Date: Tue, 29 Dec 2020 12:05:53 +0530 Subject: [PATCH] fixing unique proposal key error --- 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 930a8800891..d7077eabfda 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)