From b59c30a9c39ccab4f4427b72aa337c9f677c6d15 Mon Sep 17 00:00:00 2001 From: aman bansal Date: Tue, 12 Jan 2021 12:55:04 +0530 Subject: [PATCH] fixing unique proposal key error (#7218) (#7281) --- 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)