Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 76a9b19

Browse files
committedMar 20, 2025·
kvserver: use locks-aware naming convention
Epic: none Release note: none
1 parent 135c4b5 commit 76a9b19

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed
 

‎pkg/kv/kvserver/raft_truncator_replica.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (r *raftTruncatorReplica) getTruncatedState() kvserverpb.RaftTruncatedState
3030
}
3131

3232
func (r *raftTruncatorReplica) handleTruncationResult(ctx context.Context, pt pendingTruncation) {
33-
(*Replica)(r).handleTruncatedStateResult(ctx, pt.RaftTruncatedState,
33+
(*Replica)(r).handleTruncatedStateResultRaftMuLocked(ctx, pt.RaftTruncatedState,
3434
pt.expectedFirstIndex, pt.logDeltaBytes, pt.isDeltaTrusted)
3535
}
3636

‎pkg/kv/kvserver/replica_application_result.go

+12-9
Original file line numberDiff line numberDiff line change
@@ -498,18 +498,18 @@ func (r *Replica) handleLeaseResult(
498498
assertNoLeaseJump)
499499
}
500500

501-
// handleTruncatedStateResult is a post-apply handler for the raft log
502-
// truncation command. It updates the in-memory state of the Replica with the
503-
// new RaftTruncatedState and log size delta, and removes obsolete entries from
504-
// the raft log cache and sideloaded storage.
501+
// handleTruncatedStateResultRaftMuLocked is a post-apply handler for the raft
502+
// log truncation command. It updates the in-memory state of the Replica with
503+
// the new RaftTruncatedState and log size delta, and removes obsolete entries
504+
// from the raft log cache and sideloaded storage.
505505
//
506506
// The isDeltaTrusted flag specifies whether the raftLogDelta has been correctly
507507
// computed. The loosely coupled truncations stack sets it to false if, for
508508
// example, it failed to account for the sideloaded entries. The tightly coupled
509509
// truncations have correct stats.
510510
//
511511
// TODO(pav-kv): simplify this.
512-
func (r *Replica) handleTruncatedStateResult(
512+
func (r *Replica) handleTruncatedStateResultRaftMuLocked(
513513
ctx context.Context,
514514
t kvserverpb.RaftTruncatedState,
515515
expectedFirstIndexPreTruncation kvpb.RaftIndex,
@@ -531,7 +531,8 @@ func (r *Replica) handleTruncatedStateResult(
531531
// is truncated "logically" first, and then physically under raftMu.
532532
r.mu.Lock()
533533
r.shMu.raftTruncState = t
534-
r.handleRaftLogDeltaResult(raftLogDelta, isRaftLogTruncationDeltaTrusted)
534+
r.handleRaftLogDeltaResultRaftMuLockedReplicaMuLocked(
535+
raftLogDelta, isRaftLogTruncationDeltaTrusted)
535536
r.mu.Unlock()
536537

537538
// Clear any entries in the Raft log entry cache for this range up
@@ -558,9 +559,11 @@ func (r *Replica) handleTruncatedStateResult(
558559
// there will be dangling files at the next start. Clean them up at startup.
559560
}
560561

561-
// handleRaftLogDeltaResult updates the raft log stats with the given delta.
562-
// Both Replica.{raftMu,mu} must be held.
563-
func (r *Replica) handleRaftLogDeltaResult(delta int64, isDeltaTrusted bool) {
562+
// handleRaftLogDeltaResultRaftMuLockedReplicaMuLocked updates the raft log
563+
// stats with the given delta. Both Replica.{raftMu,mu} must be held.
564+
func (r *Replica) handleRaftLogDeltaResultRaftMuLockedReplicaMuLocked(
565+
delta int64, isDeltaTrusted bool,
566+
) {
564567
r.raftMu.AssertHeld()
565568
r.mu.AssertHeld()
566569

‎pkg/kv/kvserver/replica_application_state_machine.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ func (sm *replicaStateMachine) handleNonTrivialReplicatedEvalResult(
333333
// for the sideloaded entries.
334334
// TODO(pav-kv): remove the zero clause after any below-raft migration.
335335
logDelta := rResult.RaftLogDelta - sm.batch.truncatedSideloadedSize
336-
sm.r.handleTruncatedStateResult(ctx, *truncState, rResult.RaftExpectedFirstIndex,
337-
logDelta, true /* isDeltaTrusted */)
336+
sm.r.handleTruncatedStateResultRaftMuLocked(ctx, *truncState,
337+
rResult.RaftExpectedFirstIndex, logDelta, true /* isDeltaTrusted */)
338338
rResult.RaftLogDelta = 0
339339
rResult.RaftExpectedFirstIndex = 0
340340
}

0 commit comments

Comments
 (0)
Please sign in to comment.