Skip to content

Commit

Permalink
kv: don't try to reject lease transfer when flushing proposal buffer
Browse files Browse the repository at this point in the history
Fixes cockroachdb#83498.
Fixes cockroachdb#83402.
Fixes cockroachdb#83308.

This was fallout from cockroachdb#82758.

This commit adds logic to `propBuf.maybeRejectUnsafeProposalLocked` to avoid
trying to reject proposals based on the state of the raft group when the group
is not provided (e.g. when flushing the buffer). We already had this logic for
`RequestLease` (indirectly), but did not for `TransferLease`.
  • Loading branch information
nvanbenschoten committed Jan 13, 2023
1 parent 5306519 commit c48de09
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/kv/kvserver/replica_proposal_buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ func (b *propBuf) FlushLockedWithRaftGroup(
func (b *propBuf) maybeRejectUnsafeProposalLocked(
ctx context.Context, raftGroup proposerRaft, p *ProposalData,
) (rejected bool) {
if raftGroup == nil {
// If we do not have a raft group, we won't try to propose this proposal.
// Instead, we will register the proposal so that it can be reproposed later
// with a raft group. Wait until that point to determine whether to reject
// the proposal or not.
return false
}
switch {
case p.Request.IsSingleRequestLeaseRequest():
// Handle an edge case about lease acquisitions: we don't want to forward
Expand Down Expand Up @@ -611,9 +618,6 @@ func (b *propBuf) maybeRejectUnsafeProposalLocked(
// leaderStatusRLocked returns the rangeLeaderInfo for the provided raft group,
// or an empty rangeLeaderInfo if the raftGroup is nil.
func (b *propBuf) leaderStatusRLocked(ctx context.Context, raftGroup proposerRaft) rangeLeaderInfo {
if raftGroup == nil {
return rangeLeaderInfo{}
}
leaderInfo := b.p.leaderStatusRLocked(ctx, raftGroup)
// Sanity check.
if leaderInfo.leaderKnown && leaderInfo.leader == b.p.getReplicaID() &&
Expand Down

0 comments on commit c48de09

Please sign in to comment.