Skip to content

Commit

Permalink
kvserver: enable admitted vector protocol
Browse files Browse the repository at this point in the history
This commit enables AdmittedState annotations in RaftMessageRequest and
RaftMessageRequestBatch protocol. The leader starts receiving admitted
vector updates from all replicas.

Epic: none
Release note: none
  • Loading branch information
pav-kv committed Sep 23, 2024
1 parent 3e338af commit 1ac7e10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 0 additions & 4 deletions pkg/kv/kvserver/raft_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,6 @@ func (t *RaftTransport) processQueue(
maybeAnnotateWithAdmittedStates := func(
batch *kvserverpb.RaftMessageRequestBatch, admitted []kvflowcontrolpb.PiggybackedAdmittedState,
) {
// TODO(pav-kv): send these protos once they are populated correctly.
if true {
return
}
batch.AdmittedStates = append(batch.AdmittedStates, admitted...)
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/kv/kvserver/replica_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1944,10 +1944,12 @@ func (r *Replica) sendRaftMessage(ctx context.Context, msg raftpb.Message) {
// admitted log indices, by priority.
if msg.Type == raftpb.MsgAppResp && !msg.Reject {
admitted := r.flowControlV2.AdmittedState()
// The admitted state must be in the coordinate system of the leader's log.
if admitted.Term == msg.Term && false {
// TODO(pav-kv): enable this annotation when it is covered with tests, and
// the leader knows how to handle it.
// If admitted.Term is lagging msg.Term, sending the admitted vector has no
// effect on the leader, so skip it.
// If msg.Term is lagging the admitted.Term, this is a message to a stale
// leader. Sending it allows that leader to release all tokens. It would
// otherwise do so soon anyway, upon learning about the new leader.
if admitted.Term >= msg.Term {
req.AdmittedState = kvflowcontrolpb.AdmittedState{
Term: admitted.Term,
Admitted: admitted.Admitted[:],
Expand Down

0 comments on commit 1ac7e10

Please sign in to comment.