Skip to content

Commit fc46a13

Browse files
craig[bot]stevendanna
andcommitted
Merge #143881
143881: kvnemesis: avoid double-close of batch r=miraradeva a=stevendanna The `batch` variable that we were calling Close() on here might be overwritten if a savepoint rollback is encountered. The defer would actually then be a second Close() since we close all savepoint-generated batches in a loop. Here, we use two variables to avoid this double-close. Fixes #143873 Release note: None Co-authored-by: Steven Danna <[email protected]>
2 parents a2945c8 + f47d2f0 commit fc46a13

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/kv/kvnemesis/validator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,8 @@ func (v *validator) checkAtomicCommitted(
10381038
// it, un-hiding each of them as we encounter each write, and using the
10391039
// current state of the view as we encounter each read. Luckily this is easy
10401040
// to do by with a pebble.Batch "view".
1041-
batch := v.kvs.kvs.NewIndexedBatch()
1042-
defer func() { _ = batch.Close() }()
1041+
firstBatch := v.kvs.kvs.NewIndexedBatch()
1042+
defer func() { _ = firstBatch.Close() }()
10431043

10441044
var failure string
10451045
// writeTS is populated with the timestamp of the materialized observed writes
@@ -1068,6 +1068,7 @@ func (v *validator) checkAtomicCommitted(
10681068
// rollbackSp = observedSavepoint{...} when the observedSavepoint object
10691069
// contains a rollback for which we haven't encountered a matching create yet.
10701070
var rollbackSp *observedSavepoint = nil
1071+
batch := firstBatch
10711072
for idx := len(txnObservations) - 1; idx >= 0; idx-- {
10721073
observation := txnObservations[idx]
10731074
switch o := observation.(type) {

0 commit comments

Comments
 (0)