Skip to content

Commit 82e0600

Browse files
authoredMar 21, 2025··
Merge pull request #143195 from cockroachdb/blathers/backport-release-23.2-143191
release-23.2: kvserver: reset some fields of replicaAppBatch
2 parents ddf6a8d + 59e7a03 commit 82e0600

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎pkg/kv/kvserver/replica_application_state_machine.go

+6
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ func (sm *replicaStateMachine) NewEphemeralBatch() apply.EphemeralBatch {
139139
func (sm *replicaStateMachine) NewBatch() apply.Batch {
140140
r := sm.r
141141
b := &sm.batch
142+
// TODO(pav-kv): replicaAppBatch initialization below is bug-prone, we need to
143+
// not forget resetting the fields that are local to one batch. Find a way to
144+
// make it safer.
142145
b.r = r
143146
b.applyStats = &sm.applyStats
144147
b.batch = r.store.TODOEngine().NewBatch()
@@ -148,6 +151,9 @@ func (sm *replicaStateMachine) NewBatch() apply.Batch {
148151
*b.state.Stats = *r.mu.state.Stats
149152
b.closedTimestampSetter = r.mu.closedTimestampSetter
150153
r.mu.RUnlock()
154+
b.changeRemovesReplica = false
155+
b.changeTruncatesSideloadedFiles = false
156+
// TODO(pav-kv): what about b.ab and b.followerStoreWriteBytes?
151157
b.start = timeutil.Now()
152158
return b
153159
}

0 commit comments

Comments
 (0)
Please sign in to comment.