Skip to content

Commit 6d85793

Browse files
committed
roachtest: fix backup-restore compaction overlap bug
The previous implementation of the roachtest did not remove backup end times from the list of candidate end times for compaction after performing a compaction. This could result in scenarios where if multiple compactions were attempted, it could choose a start time of a backup that had been compacted. Because the compaction job compacts backups from an elided backup chain, those compacted backups would not appear in the list of backups and therefore the job would fail due to not being able to find the starting backup. Informs: #144216 Release note: None
1 parent 77c11b1 commit 6d85793

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/cmd/roachtest/tests/mixed_version_backup.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"path/filepath"
1616
"reflect"
1717
"regexp"
18+
"slices"
1819
"sort"
1920
"strings"
2021
"sync"
@@ -2076,7 +2077,7 @@ func (d *BackupRestoreTestDriver) createBackupCollection(
20762077
numIncrementals = 2
20772078
}
20782079
l.Printf("creating %d incremental backups", numIncrementals)
2079-
for i := 0; i < numIncrementals; i++ {
2080+
for i := range numIncrementals {
20802081
d.randomWait(l, rng)
20812082
if err := d.testUtils.runJobOnOneOf(ctx, l, incBackupSpec.Execute.Nodes, func() error {
20822083
var err error
@@ -2117,6 +2118,14 @@ func (d *BackupRestoreTestDriver) createBackupCollection(
21172118
}); err != nil {
21182119
return nil, err
21192120
}
2121+
// Since a compacted backup was made, then the backup end times of the
2122+
// backups it compacted should be removed from the slice. This prevents a
2123+
// scenario where a later compaction attempts to pick a start time from
2124+
// one of the backups that were compacted. Since compaction looks at the
2125+
// elided backup chain, these compacted backups are replaced by the
2126+
// compacted backup and compaction will fail due to being unable to find
2127+
// the starting backup.
2128+
backupEndTimes = slices.Delete(backupEndTimes, startIdx+1, endIdx)
21202129
}
21212130
}
21222131

0 commit comments

Comments
 (0)