Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: conditionally handleReady after tick #138357

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkg/kv/kvserver/replica_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,11 +1423,11 @@ func maybeFatalOnRaftReadyErr(ctx context.Context, err error) (removed bool) {
// be queued for Ready processing; false otherwise.
func (r *Replica) tick(
ctx context.Context, livenessMap livenesspb.IsLiveMap, ioThresholdMap *ioThresholdMap,
) (exists bool, err error) {
) (processReady bool, err error) {
r.raftMu.Lock()
defer r.raftMu.Unlock()
defer func() {
if exists && err == nil {
if processReady && err == nil {
// NB: since we are returning true, there will be a Ready handling
// immediately after this call, so any pings stashed in raft will be sent.
// NB: Replica.mu must not be held here.
Expand Down Expand Up @@ -1530,7 +1530,9 @@ func (r *Replica) tick(
// have been pending for 1 to 2 reproposal timeouts.
r.refreshProposalsLocked(ctx, refreshAtDelta, reasonTicks)
}
return true, nil

processReady = r.mu.internalRaftGroup.HasReady()
return processReady, nil
}

func (r *Replica) processRACv2PiggybackedAdmitted(ctx context.Context) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kv/kvserver/store_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,12 @@ func (s *Store) processTick(_ context.Context, rangeID roachpb.RangeID) bool {
start := timeutil.Now()
ctx := r.raftCtx

exists, err := r.tick(ctx, livenessMap, ioThresholds)
processReady, err := r.tick(ctx, livenessMap, ioThresholds)
if err != nil {
log.Errorf(ctx, "%v", err)
}
s.metrics.RaftTickingDurationNanos.Inc(timeutil.Since(start).Nanoseconds())
return exists // ready
return processReady
}

func (s *Store) processRACv2PiggybackedAdmitted(ctx context.Context, rangeID roachpb.RangeID) {
Expand Down
Loading