Skip to content

Commit 48c636e

Browse files
craig[bot]msbutler
andcommitted
Merge #150451
150451: restore: mark pebble corruption errors on backup file reads as failures r=dt a=msbutler Fixes #150258 Release note: none Co-authored-by: Michael Butler <[email protected]>
2 parents ac400e7 + 609188b commit 48c636e

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

pkg/backup/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ go_library(
159159
"//pkg/util/uuid",
160160
"@com_github_cockroachdb_errors//:errors",
161161
"@com_github_cockroachdb_logtags//:logtags",
162+
"@com_github_cockroachdb_pebble//:pebble",
162163
"@com_github_cockroachdb_redact//:redact",
163164
"@com_github_gogo_protobuf//types",
164165
"@com_github_robfig_cron_v3//:cron",

pkg/backup/restore_data_processor.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ func (rd *restoreDataProcessor) runRestoreWorkers(
454454
})
455455
}
456456

457+
var backupFileReadError = errors.New("error reading backup file")
458+
457459
func (rd *restoreDataProcessor) processRestoreSpanEntry(
458460
ctx context.Context, kr *KeyRewriter, sst mergedSST,
459461
) (kvpb.BulkOpSummary, error) {
@@ -537,9 +539,8 @@ func (rd *restoreDataProcessor) processRestoreSpanEntry(
537539
for iter.SeekGE(startKeyMVCC); ; iter.NextKey() {
538540
ok, err := iter.Valid()
539541
if err != nil {
540-
return summary, err
542+
return summary, errors.Join(backupFileReadError, err)
541543
}
542-
543544
if !ok {
544545
if verbose {
545546
log.Infof(ctx, "iterator exhausted")
@@ -560,12 +561,12 @@ func (rd *restoreDataProcessor) processRestoreSpanEntry(
560561

561562
v, err := iter.UnsafeValue()
562563
if err != nil {
563-
return summary, err
564+
return summary, errors.Join(backupFileReadError, err)
564565
}
565566
valueScratch = append(valueScratch[:0], v...)
566567
value, err := storage.DecodeValueFromMVCCValue(valueScratch)
567568
if err != nil {
568-
return summary, err
569+
return summary, errors.Join(backupFileReadError, err)
569570
}
570571

571572
key.Key, ok, err = kr.RewriteKey(key.Key, key.Timestamp.WallTime)

pkg/backup/restore_job.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import (
7979
"github.com/cockroachdb/cockroach/pkg/util/tracing"
8080
"github.com/cockroachdb/cockroach/pkg/util/uuid"
8181
"github.com/cockroachdb/errors"
82+
"github.com/cockroachdb/pebble"
8283
)
8384

8485
var (
@@ -215,6 +216,10 @@ func restoreWithRetry(
215216
if errors.HasType(err, &kvpb.InsufficientSpaceError{}) {
216217
return roachpb.RowCount{}, jobs.MarkPauseRequestError(errors.UnwrapAll(err))
217218
}
219+
220+
if pebble.IsCorruptionError(err) && errors.Is(err, backupFileReadError) {
221+
return roachpb.RowCount{}, jobs.MarkAsPermanentJobError(err)
222+
}
218223
// If we are draining, it is unlikely we can start a
219224
// new DistSQL flow. Exit with a retryable error so
220225
// that another node can pick up the job.

0 commit comments

Comments
 (0)