Skip to content

Commit

Permalink
replica_rac2: fix is leader v2 protocol when leader
Browse files Browse the repository at this point in the history
The `Processor` calls `isLeaderUsingV2ProcLocked` to determine which
store work queue admit method to call, opting for the v1 method if
`isLeaderUsingV2ProcLocked` returns false.

Update `isLeaderUsingV2ProcLocked` to correctly return false when the
local replica is the leader and running v1, having previously seen a
leader running v2.

Part of: cockroachdb#130431
Release note: None
  • Loading branch information
kvoli committed Sep 24, 2024
1 parent 04d6f33 commit b6fb650
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/kv/kvserver/kvflowcontrol/replica_rac2/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ func NewProcessor(opts ProcessorOptions) Processor {
func (p *processorImpl) isLeaderUsingV2ProcLocked() bool {
// We are the leader using V2, or a follower who learned that the leader is
// using the V2 protocol.
return p.leader.rc != nil || p.follower.isLeaderUsingV2Protocol
return p.leader.rc != nil || (p.opts.ReplicaID != p.leaderID && p.follower.isLeaderUsingV2Protocol)
}

// InitRaftLocked implements Processor.
Expand Down Expand Up @@ -901,7 +901,7 @@ func (p *processorImpl) AdmitRaftEntriesRaftMuLocked(ctx context.Context, e rac2
log.Infof(ctx,
"decoded v2 raft admission meta below-raft: pri=%v create-time=%d "+
"proposer=n%v receiver=[n%d,s%v] tenant=t%d tokens≈%d "+
"sideloaded=%t raft-entry=%d/%d",
"sideloaded=%t raft-entry=%d/%d lead-v2=%v",
raftpb.Priority(meta.AdmissionPriority),
meta.AdmissionCreateTime,
meta.AdmissionOriginNode,
Expand All @@ -912,12 +912,13 @@ func (p *processorImpl) AdmitRaftEntriesRaftMuLocked(ctx context.Context, e rac2
typ.IsSideloaded(),
entry.Term,
entry.Index,
p.isLeaderUsingV2ProcLocked(),
)
} else {
log.Infof(ctx,
"decoded v1 raft admission meta below-raft: pri=%v create-time=%d "+
"proposer=n%v receiver=[n%d,s%v] tenant=t%d tokens≈%d "+
"sideloaded=%t raft-entry=%d/%d",
"sideloaded=%t raft-entry=%d/%d lead-v2=%v",
admissionpb.WorkPriority(meta.AdmissionPriority),
meta.AdmissionCreateTime,
meta.AdmissionOriginNode,
Expand All @@ -928,6 +929,7 @@ func (p *processorImpl) AdmitRaftEntriesRaftMuLocked(ctx context.Context, e rac2
typ.IsSideloaded(),
entry.Term,
entry.Index,
p.isLeaderUsingV2ProcLocked(),
)
}
}
Expand Down

0 comments on commit b6fb650

Please sign in to comment.