@@ -197,26 +197,27 @@ func DecompressData(ctx context.Context, mem *mon.BoundAccount, descBytes []byte
197
197
198
198
// ReadBackupCheckpointManifest reads and unmarshals a BACKUP-CHECKPOINT
199
199
// manifest from filename in the provided export store.
200
+ //
201
+ // NB: a checkpoint file should always get written before this is called.
200
202
func ReadBackupCheckpointManifest (
201
203
ctx context.Context ,
202
204
mem * mon.BoundAccount ,
203
205
exportStore cloud.ExternalStorage ,
204
- filename string ,
205
206
encryption * jobspb.BackupEncryptionOptions ,
206
207
kmsEnv cloud.KMSEnv ,
207
208
) (backuppb.BackupManifest , int64 , error ) {
208
209
ctx , sp := tracing .ChildSpan (ctx , "backupinfo.ReadBackupCheckpointManifest" )
209
210
defer sp .Finish ()
210
211
211
- checkpointFile , err := readLatestCheckpointFile (ctx , exportStore , filename )
212
+ checkpointFile , err := readLatestCheckpointFile (ctx , exportStore , BackupManifestCheckpointName )
212
213
if err != nil {
213
214
return backuppb.BackupManifest {}, 0 , err
214
215
}
215
216
defer checkpointFile .Close (ctx )
216
217
217
218
// Look for a checksum, if one is not found it could be an older backup,
218
219
// but we want to continue anyway.
219
- checksumFile , err := readLatestCheckpointFile (ctx , exportStore , filename + BackupManifestChecksumSuffix )
220
+ checksumFile , err := readLatestCheckpointFile (ctx , exportStore , BackupManifestCheckpointName + BackupManifestChecksumSuffix )
220
221
if err != nil {
221
222
if ! errors .Is (err , cloud .ErrFileDoesNotExist ) {
222
223
return backuppb.BackupManifest {}, 0 , err
@@ -1278,17 +1279,6 @@ func CheckForBackupLock(
1278
1279
// 2) BACKUP-LOCK: Written by the coordinator node to lay claim on a backup
1279
1280
// location. This file is suffixed with the ID of the backup job to prevent a
1280
1281
// node from reading its own lock file on job resumption.
1281
- //
1282
- // 3) BACKUP-CHECKPOINT: Prior to 22.1.1, nodes would use the BACKUP-CHECKPOINT
1283
- // to lay claim on a backup location. To account for a mixed-version cluster
1284
- // where an older coordinator node may be running a concurrent backup to the
1285
- // same location, we must continue to check for a BACKUP-CHECKPOINT file.
1286
- //
1287
- // NB: The node will continue to write a BACKUP-CHECKPOINT file later in its
1288
- // execution, but we do not have to worry about reading our own
1289
- // BACKUP-CHECKPOINT file (and locking ourselves out) since
1290
- // `checkForPreviousBackup` is invoked as the first step on job resumption, and
1291
- // is not called again.
1292
1282
func CheckForPreviousBackup (
1293
1283
ctx context.Context ,
1294
1284
execCfg * sql.ExecutorConfig ,
@@ -1343,35 +1333,9 @@ func CheckForPreviousBackup(
1343
1333
}
1344
1334
log .Dev .Warningf (ctx , "external storage %s does not support listing: skip checking for BACKUP_LOCK" , redactedURI )
1345
1335
}
1346
-
1347
- // Check for a BACKUP-CHECKPOINT that might have been written by a node
1348
- // running a pre-22.1.1 binary.
1349
- //
1350
- // TODO(adityamaru): Delete in 23.1 since we will no longer need to check for
1351
- // BACKUP-CHECKPOINT files as all backups will rely on BACKUP-LOCK to lock a
1352
- // location.
1353
- r , err = readLatestCheckpointFile (ctx , defaultStore , BackupManifestCheckpointName )
1354
- if err == nil {
1355
- r .Close (ctx )
1356
- return pgerror .Newf (pgcode .FileAlreadyExists ,
1357
- "%s already contains a %s file (is another operation already in progress?)" ,
1358
- redactedURI , BackupManifestCheckpointName )
1359
- }
1360
-
1361
- if ! errors .Is (err , cloud .ErrFileDoesNotExist ) {
1362
- return errors .Wrapf (err ,
1363
- "%s returned an unexpected error when checking for the existence of %s file" ,
1364
- redactedURI , BackupManifestCheckpointName )
1365
- }
1366
-
1367
1336
return nil
1368
1337
}
1369
1338
1370
- // TempCheckpointFileNameForJob returns temporary filename for backup manifest checkpoint.
1371
- func TempCheckpointFileNameForJob (jobID jobspb.JobID ) string {
1372
- return fmt .Sprintf ("%s-%d" , BackupManifestCheckpointName , jobID )
1373
- }
1374
-
1375
1339
// BackupManifestDescriptors returns the descriptors encoded in the manifest as
1376
1340
// a slice of mutable descriptors.
1377
1341
func BackupManifestDescriptors (
@@ -1440,11 +1404,8 @@ func newDescriptorBuilder(
1440
1404
return nil
1441
1405
}
1442
1406
1443
- // WriteBackupManifestCheckpoint writes a new BACKUP-CHECKPOINT MANIFEST and
1444
- // CHECKSUM file. If it is a pure v22.1 cluster or later, it will write a
1445
- // timestamped BACKUP-CHECKPOINT to the /progress directory. If it is a mixed
1446
- // cluster version, it will write a non timestamped BACKUP-CHECKPOINT to the
1447
- // base directory in order to not break backup jobs that resume on a v21.2 node.
1407
+ // WriteBackupManifestCheckpoint writes a BACKUP-CHECKPOINT file and CHECKSUM
1408
+ // file.
1448
1409
func WriteBackupManifestCheckpoint (
1449
1410
ctx context.Context ,
1450
1411
storageURI string ,
@@ -1545,12 +1506,9 @@ func readLatestCheckpointFile(
1545
1506
ctx context.Context , exportStore cloud.ExternalStorage , filename string ,
1546
1507
) (ioctx.ReadCloserCtx , error ) {
1547
1508
filename = strings .TrimPrefix (filename , "/" )
1548
- // First try reading from the progress directory. If the backup is from
1549
- // an older version, it may not exist there yet so try reading
1550
- // in the base directory if the first attempt fails.
1509
+
1551
1510
var checkpoint string
1552
1511
var checkpointFound bool
1553
- var r ioctx.ReadCloserCtx
1554
1512
var err error
1555
1513
1556
1514
// We name files such that the most recent checkpoint will always
@@ -1571,7 +1529,7 @@ func readLatestCheckpointFile(
1571
1529
// directly. This can still fail if it is a mixed cluster and the
1572
1530
// checkpoint was written in the base directory.
1573
1531
if errors .Is (err , cloud .ErrListingUnsupported ) {
1574
- r , _ , err = exportStore .ReadFile (ctx , BackupProgressDirectory + "/" + filename , cloud.ReadOptions {NoFileSize : true })
1532
+ r , _ , err : = exportStore .ReadFile (ctx , BackupProgressDirectory + "/" + filename , cloud.ReadOptions {NoFileSize : true })
1575
1533
// If we found the checkpoint in progress, then don't bother reading
1576
1534
// from base, just return the reader.
1577
1535
if err == nil {
@@ -1581,26 +1539,18 @@ func readLatestCheckpointFile(
1581
1539
return nil , err
1582
1540
}
1583
1541
1584
- if checkpointFound {
1585
- var name string
1586
- if strings .HasSuffix (filename , BackupManifestChecksumSuffix ) {
1587
- name = BackupProgressDirectory + "/" + checkpoint + BackupManifestChecksumSuffix
1588
- } else {
1589
- name = BackupProgressDirectory + "/" + checkpoint
1590
- }
1591
- r , _ , err = exportStore .ReadFile (ctx , name , cloud.ReadOptions {NoFileSize : true })
1592
- return r , err
1542
+ if ! checkpointFound {
1543
+ return nil , errors .Newf ("latest file %s not found" , filename )
1593
1544
}
1594
1545
1595
- // If the checkpoint wasn't found in the progress directory, then try
1596
- // reading from the base directory instead.
1597
- r , _ , err = exportStore .ReadFile (ctx , filename , cloud.ReadOptions {NoFileSize : true })
1598
-
1599
- if err != nil {
1600
- return nil , errors .Wrapf (err , "%s could not be read in the base or progress directory" , filename )
1546
+ var name string
1547
+ if strings .HasSuffix (filename , BackupManifestChecksumSuffix ) {
1548
+ name = BackupProgressDirectory + "/" + checkpoint + BackupManifestChecksumSuffix
1549
+ } else {
1550
+ name = BackupProgressDirectory + "/" + checkpoint
1601
1551
}
1602
- return r , nil
1603
-
1552
+ r , _ , err := exportStore . ReadFile ( ctx , name , cloud. ReadOptions { NoFileSize : true })
1553
+ return r , err
1604
1554
}
1605
1555
1606
1556
// NewTimestampedCheckpointFileName returns a string of a new checkpoint filename
0 commit comments