Skip to content

Commit 84fd608

Browse files
craig[bot]msbutler
andcommitted
Merge #153907
153907: backup: teach ContainsManifest to use the up to date manifest file r=kev-cao a=msbutler In addition, this patch adds some todos on the plan to delete the deprecated backup manifest. Informs #139159 Release note: none Co-authored-by: Michael Butler <[email protected]>
2 parents 118aaf8 + 72ae949 commit 84fd608

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

pkg/backup/backup_job.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,10 @@ func backup(
428428
}
429429

430430
// TODO(msbutler): version gate writing the old manifest once we can guarantee
431-
// a cluster version that will not read the old manifest.
431+
// a cluster version that will not read the old manifest. This will occur when we delete
432+
// LegacyFindPriorBackups and the fallback path in
433+
// ListFullBackupsInCollection, which can occur when we completely rely on the
434+
// backup index.
432435
if err := backupinfo.WriteBackupManifest(ctx, defaultStore, backupbase.DeprecatedBackupManifestName,
433436
encryption, &kmsEnv, backupManifest); err != nil {
434437
return roachpb.RowCount{}, 0, err

pkg/backup/backupdest/backup_destination.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252
// On some cloud storage platforms (i.e. GS, S3), backups in a base bucket may
5353
// omit a leading slash. However, backups in a subdirectory of a base bucket
5454
// will contain one.
55-
var backupPathRE = regexp.MustCompile("^/?[^\\/]+/[^\\/]+/[^\\/]+/" + backupbase.DeprecatedBackupManifestName + "$")
55+
var deprecatedBackupPathRE = regexp.MustCompile("^/?[^\\/]+/[^\\/]+/[^\\/]+/" + backupbase.DeprecatedBackupManifestName + "$")
5656

5757
// ResolvedDestination encapsulates information that is populated while
5858
// resolving the destination of a backup.
@@ -483,7 +483,7 @@ func ListFullBackupsInCollection(
483483

484484
var backupPaths []string
485485
if err := store.List(ctx, "", backupbase.ListingDelimDataSlash, func(f string) error {
486-
if backupPathRE.MatchString(f) {
486+
if deprecatedBackupPathRE.MatchString(f) {
487487
backupPaths = append(backupPaths, f)
488488
}
489489
return nil

pkg/backup/backupdest/incrementals.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ func FindAllIncrementalPaths(
122122
//
123123
// Note: store should be rooted at the directory containing the incremental
124124
// backups (i.e. gs://my-bucket/backup/incrementals/2025/07/29-123456.00/)
125+
//
126+
// TODO (msbutler): we didn't bother to update this to use the up to date
127+
// manifest as this will eventually be deleted when all reads use the index.
125128
func LegacyFindPriorBackups(
126129
ctx context.Context, store cloud.ExternalStorage, includeManifest bool,
127130
) ([]string, error) {

pkg/backup/backupinfo/manifest_handling.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,22 @@ func ReadBackupManifestFromStore(
169169
}
170170

171171
func ContainsManifest(ctx context.Context, exportStore cloud.ExternalStorage) (bool, error) {
172-
r, _, err := exportStore.ReadFile(ctx, backupbase.DeprecatedBackupManifestName, cloud.ReadOptions{NoFileSize: true})
173-
if err != nil {
174-
if errors.Is(err, cloud.ErrFileDoesNotExist) {
175-
return false, nil
172+
containsManifestWithFilename := func(filename string) (bool, error) {
173+
r, _, err := exportStore.ReadFile(ctx, filename, cloud.ReadOptions{NoFileSize: true})
174+
if err != nil {
175+
if errors.Is(err, cloud.ErrFileDoesNotExist) {
176+
return false, nil
177+
}
178+
return false, err
176179
}
177-
return false, err
180+
r.Close(ctx)
181+
return true, nil
182+
}
183+
exists, err := containsManifestWithFilename(backupbase.BackupMetadataName)
184+
if exists || err != nil {
185+
return exists, err
178186
}
179-
r.Close(ctx)
180-
return true, nil
187+
return containsManifestWithFilename(backupbase.DeprecatedBackupManifestName)
181188
}
182189

183190
// compressData compresses data buffer and returns compressed
@@ -1310,13 +1317,13 @@ func CheckForPreviousBackup(
13101317
exists, err := ContainsManifest(ctx, defaultStore)
13111318
if err != nil {
13121319
return errors.Wrapf(err,
1313-
"%s returned an unexpected error when checking for the existence of %s file",
1314-
redactedURI, backupbase.DeprecatedBackupManifestName)
1320+
"%s returned an unexpected error when checking for the existence of manifest",
1321+
redactedURI)
13151322
}
13161323
if exists {
13171324
return pgerror.Newf(pgcode.FileAlreadyExists,
1318-
"%s already contains a %s file",
1319-
redactedURI, backupbase.DeprecatedBackupManifestName)
1325+
"%s already contains a manifest",
1326+
redactedURI)
13201327
}
13211328

13221329
// Check for the presence of a BACKUP-LOCK file with a job ID different from

0 commit comments

Comments
 (0)