Skip to content

Commit 53ce6cb

Browse files
craig[bot]jeffswenson
andcommitted
Merge #151148
151148: backupinfo: fix error handling in desciter r=jeffswenson a=jeffswenson Previously, the DescIter.Valid would return (false, nil) if the underlying SST iterator was in an error state. This is an "empty" state when it needs to propagate the error. Fixes: #151144 Release note: Fixes a rare bug in restore where an object storage on restore start could cause restore to report success without creating the restored tables or databases. Co-authored-by: Jeff Swenson <jeffswenson@betterthannull.com>
2 parents 9919801 + 8efbd4d commit 53ce6cb

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

pkg/backup/backupinfo/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ go_library(
5858
go_test(
5959
name = "backupinfo_test",
6060
srcs = [
61+
"desc_sst_test.go",
6162
"main_test.go",
6263
"manifest_handling_test.go",
6364
],
65+
embed = [":backupinfo"],
6466
deps = [
65-
":backupinfo",
6667
"//pkg/backup/backuppb",
6768
"//pkg/base",
6869
"//pkg/blobs",
@@ -86,6 +87,7 @@ go_test(
8687
"//pkg/util/leaktest",
8788
"//pkg/util/log",
8889
"//pkg/util/randutil",
90+
"@com_github_cockroachdb_errors//:errors",
8991
"@com_github_stretchr_testify//require",
9092
],
9193
)

pkg/backup/backupinfo/desc_sst.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ func (di *DescIterator) Next() {
303303
break
304304
}
305305
}
306+
if di.backing.iterError != nil {
307+
di.err = di.backing.iterError
308+
return
309+
}
306310

307311
di.value = nextValue
308312
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2025 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the CockroachDB Software License
4+
// included in the /LICENSE file.
5+
6+
package backupinfo
7+
8+
import (
9+
"testing"
10+
11+
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
12+
"github.com/cockroachdb/cockroach/pkg/util/log"
13+
"github.com/cockroachdb/errors"
14+
"github.com/stretchr/testify/require"
15+
)
16+
17+
func TestDescSSTError(t *testing.T) {
18+
defer leaktest.AfterTest(t)()
19+
defer log.Scope(t).Close(t)
20+
21+
iter := &DescIterator{
22+
backing: bytesIter{
23+
iterError: errors.New("internal iterator error"),
24+
},
25+
}
26+
27+
iter.Next()
28+
29+
valid, err := iter.Valid()
30+
require.False(t, valid)
31+
require.Error(t, err)
32+
}

0 commit comments

Comments
 (0)