Skip to content

Commit

Permalink
kvserver: assert uniqueness in registerProposalLocked
Browse files Browse the repository at this point in the history
We routinely overwrite entries in the `r.mu.proposals` map. That is
"fine" (better if we didn't, but currently it is by design - it
happens in refreshProposalsLocked and during
tryReproposeWithNewLeaseIndex) but our overwrites should be no-ops, i.e.
reference the exact same `*ProposalData`.

This is now asserted.

One way this would trip is a CmdID collision.

Epic: none
Release note: None
  • Loading branch information
tbg committed Feb 23, 2023
1 parent dd2749a commit f8a9d40
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/kv/kvserver/replica_proposal_buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,9 @@ func (rp *replicaProposer) registerProposalLocked(p *ProposalData) {
if buildutil.CrdbTestBuild && (p.ec.repl == nil || p.ec.g == nil) {
log.Fatalf(rp.store.AnnotateCtx(context.Background()), "finished proposal inserted into map: %+v", p)
}
if prev := rp.mu.proposals[p.idKey]; prev != nil && prev != p {
log.Fatalf(rp.store.AnnotateCtx(context.Background()), "two proposals under same ID:\n%+v,\n%+v", prev, p)
}
rp.mu.proposals[p.idKey] = p
}

Expand Down

0 comments on commit f8a9d40

Please sign in to comment.