Skip to content

Commit b637406

Browse files
committed
kvserver: inline some no-longer-shared code
1 parent 1b7f4a2 commit b637406

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

pkg/kv/kvserver/replica_application_result.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -506,20 +506,6 @@ func (r *Replica) stagePendingTruncationRaftMuLocked(pt pendingTruncation) {
506506
r.asLogStorage().stagePendingTruncationRaftMuLocked(pt)
507507
}
508508

509-
func (r *replicaLogStorage) stagePendingTruncationSharedRaftMuLockedMuLocked(pt pendingTruncation) {
510-
// This code is shared between regular log truncations and snapshot-induced
511-
// truncations.
512-
r.shMu.trunc = pt.RaftTruncatedState
513-
// Ensure the raft log size is not negative since it isn't persisted between
514-
// server restarts.
515-
// TODO(pav-kv): should we distrust the log size if it goes negative?
516-
r.shMu.size = max(r.shMu.size+pt.logDeltaBytes, 0)
517-
r.shMu.lastCheckSize = max(r.shMu.lastCheckSize+pt.logDeltaBytes, 0)
518-
if !pt.isDeltaTrusted {
519-
r.shMu.sizeTrusted = false
520-
}
521-
}
522-
523509
func (r *replicaLogStorage) stageApplySnapshot(truncState kvserverpb.RaftTruncatedState) {
524510
r.raftMu.AssertHeld()
525511

@@ -584,7 +570,15 @@ func (r *replicaLogStorage) stagePendingTruncationRaftMuLocked(pt pendingTruncat
584570
func() {
585571
r.mu.Lock()
586572
defer r.mu.Unlock()
587-
r.stagePendingTruncationSharedRaftMuLockedMuLocked(pt)
573+
r.shMu.trunc = pt.RaftTruncatedState
574+
// Ensure the raft log size is not negative since it isn't persisted between
575+
// server restarts.
576+
// TODO(pav-kv): should we distrust the log size if it goes negative?
577+
r.shMu.size = max(r.shMu.size+pt.logDeltaBytes, 0)
578+
r.shMu.lastCheckSize = max(r.shMu.lastCheckSize+pt.logDeltaBytes, 0)
579+
if !pt.isDeltaTrusted {
580+
r.shMu.sizeTrusted = false
581+
}
588582
}()
589583

590584
// Clear entries in the raft log entry cache for this range up to and

0 commit comments

Comments
 (0)