Skip to content

Commit

Permalink
rac2: fixes to send-queue metrics maintained by rangeController
Browse files Browse the repository at this point in the history
Epic: CRDB-37515

Release note: None
  • Loading branch information
sumeerbhola committed Oct 11, 2024
1 parent 34316ac commit 673466e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions pkg/kv/kvserver/kvflowcontrol/rac2/range_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2221,9 +2221,6 @@ func (rss *replicaSendStream) closeLocked(ctx context.Context) {
rss.returnSendTokens(ctx, rss.mu.tracker.UntrackAll(), true /* disconnect */)
rss.returnAllEvalTokensLocked(ctx)
rss.stopAttemptingToEmptySendQueueLocked(ctx, true)
if rss.mu.sendQueue.forceFlushScheduled {
rss.parent.parent.opts.RangeControllerMetrics.SendQueue.ForceFlushedScheduledCount.Dec(1)
}
rss.mu.closed = true
}

Expand Down Expand Up @@ -2487,10 +2484,14 @@ func (rss *replicaSendStream) dequeueFromQueueAndSendLocked(
} else {
tokensNeeded = 0
}
sendQueueMetrics := rss.parent.parent.opts.RangeControllerMetrics.SendQueue
afterDeductedTokens := rss.mu.sendQueue.deductedForSchedulerTokens
if buildutil.CrdbTestBuild && beforeDeductedTokens < afterDeductedTokens {
panic(errors.AssertionFailedf("beforeDeductedTokens %s < afterDeductedTokens %s",
beforeDeductedTokens, afterDeductedTokens))
}
if beforeDeductedTokens > afterDeductedTokens {
sendQueueMetrics.DeductedForSchedulerBytes.Dec(int64(afterDeductedTokens - beforeDeductedTokens))
sendQueueMetrics := rss.parent.parent.opts.RangeControllerMetrics.SendQueue
sendQueueMetrics.DeductedForSchedulerBytes.Dec(int64(beforeDeductedTokens - afterDeductedTokens))
}
}
if tokensNeeded > 0 {
Expand Down Expand Up @@ -2542,8 +2543,10 @@ func (rss *replicaSendStream) changeToProbeLocked(ctx context.Context, now time.
func (rss *replicaSendStream) stopAttemptingToEmptySendQueueLocked(
ctx context.Context, disconnect bool,
) {
rss.mu.sendQueue.forceFlushScheduled = false
rss.parent.parent.opts.RangeControllerMetrics.SendQueue.ForceFlushedScheduledCount.Dec(1)
if rss.mu.sendQueue.forceFlushScheduled {
rss.mu.sendQueue.forceFlushScheduled = false
rss.parent.parent.opts.RangeControllerMetrics.SendQueue.ForceFlushedScheduledCount.Dec(1)
}
rss.stopAttemptingToEmptySendQueueViaWatcherLocked(ctx, disconnect)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ metrics type=send_queue
----
kvflowcontrol.send_queue.count : 2
kvflowcontrol.send_queue.bytes : 2097152
kvflowcontrol.send_queue.scheduled.force_flush : 0
kvflowcontrol.send_queue.scheduled.force_flush : 1
kvflowcontrol.send_queue.scheduled.deducted_bytes : 0
kvflowcontrol.send_queue.prevent.count : 0
kvflowcontrol.tokens.send.elastic.deducted.force_flush_send_queue : 0
Expand Down

0 comments on commit 673466e

Please sign in to comment.