Skip to content

Commit 24603c9

Browse files
craig[bot]irfansharif
andcommitted
107412: kvserver: fix 'observed raft log position' assertion r=irfansharif a=irfansharif Fixes cockroachdb#107336. Fixes cockroachdb#106123. Fixes cockroachdb#107156. Fixes cockroachdb#106589. It's possible to hit this assertion under --stress --race when the proposing replica is starved enough for raft ticks that it loses leadership right when it steps proposals through raft. We're relying on undocumented API semantics in the etcd raft library whereby it mutates stepped entries with the term+index its to end up in. But that's only applicable if stepping through entries as a leader. Simply relax this assertion instead. Release note: None Co-authored-by: irfan sharif <[email protected]>
2 parents d293bb3 + deb538f commit 24603c9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/kv/kvserver/replica_proposal_buf.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,16 @@ func maybeDeductFlowTokens(
10411041
if admitHandle.handle == nil {
10421042
continue // nothing to do
10431043
}
1044+
if ents[i].Term == 0 && ents[i].Index == 0 {
1045+
// It's possible to have lost raft leadership right before stepping
1046+
// proposals through raft. They'll get forwarded to the new raft
1047+
// leader, and for flow token purposes, there's no tracking
1048+
// necessary. The token deductions below asserts on monotonic
1049+
// observations of log positions, which this empty position would
1050+
// otherwise violate. There's integration code elsewhere that will
1051+
// free up all tracked tokens as a result of this leadership change.
1052+
return
1053+
}
10441054
log.VInfof(ctx, 1, "bound index/log terms for proposal entry: %s",
10451055
raft.DescribeEntry(ents[i], func(bytes []byte) string {
10461056
return "<omitted>"

0 commit comments

Comments
 (0)