Skip to content

Commit

Permalink
Merge #94872
Browse files Browse the repository at this point in the history
94872: kv: fix handleRaftReady duration computation r=nvanbenschoten a=nvanbenschoten

This was unintentionally broken by fde6267, despite the prescient comment a few lines down.

As a result, `raft.process.handleready.latency` and `raft.process.workingnanos` were both broken.

Epic: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
Co-authored-by: Tobias Grieger <[email protected]>
  • Loading branch information
3 people committed Jan 24, 2023
2 parents 74d4dea + 5335649 commit dc974cd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/kv/kvserver/replica_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,20 +684,21 @@ func (r *Replica) handleRaftReady(
// non-sensitive cue as to what happened.
func (r *Replica) handleRaftReadyRaftMuLocked(
ctx context.Context, inSnap IncomingSnapshot,
) (handleRaftReadyStats, error) {
) (stats handleRaftReadyStats, _ error) {
// handleRaftReadyRaftMuLocked is not prepared to handle context cancellation,
// so assert that it's given a non-cancellable context.
if ctx.Done() != nil {
return handleRaftReadyStats{}, errors.AssertionFailedf(
"handleRaftReadyRaftMuLocked cannot be called with a cancellable context")
}

stats := handleRaftReadyStats{
// NB: we need to reference the named return parameter here. If `stats` were
// just a local, we'd be modifying the local but not the return value in the
// defer below.
stats = handleRaftReadyStats{
tBegin: timeutil.Now(),
}
defer func() {
// NB: we need to reference the named return parameter here. If `stats` were
// just a local, we'd be modifying the local but not the return value.
stats.tEnd = timeutil.Now()
}()

Expand Down

0 comments on commit dc974cd

Please sign in to comment.