Skip to content

Commit

Permalink
fixing unique proposal key error (#7218)
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-bansal committed Jan 12, 2021
1 parent 764ac49 commit 96ea000
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dgraph/cmd/zero/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 96ea000

Please sign in to comment.