Skip to content

Commit f0c3192

Browse files
author
michael stack
committed
Call describeBackup w/ invalidVersion so metadata is written when blobstore url
1 parent c8881b2 commit f0c3192

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

fdbbackup/backup.actor.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ enum class DBType { UNDEFINED = 0, START, STATUS, SWITCH, ABORT, PAUSE, RESUME }
109109
// New fast restore reuses the type from legacy slow restore
110110
enum class RestoreType { UNKNOWN, START, STATUS, ABORT, WAIT };
111111

112+
// Helper function to check if a URL is a blobstore:// URL
113+
// For blobstore:// URLs, describeBackup needs to use invalidVersion to allow writing missing version properties
114+
// This is needed for S3 where metadata may not be immediately consistent
115+
static inline bool isBlobstoreUrl(const std::string& url) {
116+
return url.find("blobstore://") == 0;
117+
}
118+
112119
//
113120
enum {
114121
// Backup constants
@@ -2405,7 +2412,8 @@ ACTOR Future<Void> runRestore(Database db,
24052412
printf(
24062413
"No restore target version given, will use maximum restorable version from backup description.\n");
24072414

2408-
BackupDescription desc = wait(bc->describeBackup());
2415+
// For blobstore:// URLs, use invalidVersion to allow describeBackup to write missing version properties
2416+
BackupDescription desc = wait(bc->describeBackup(false, isBlobstoreUrl(container) ? invalidVersion : 0));
24092417

24102418
if (onlyApplyMutationLogs && desc.contiguousLogEnd.present()) {
24112419
targetVersion = desc.contiguousLogEnd.get() - 1;
@@ -2501,7 +2509,10 @@ ACTOR Future<Void> runFastRestoreTool(Database db,
25012509
if (performRestore) {
25022510
if (dbVersion == invalidVersion) {
25032511
TraceEvent("FastRestoreTool").detail("TargetRestoreVersion", "Largest restorable version");
2504-
BackupDescription desc = wait(IBackupContainer::openContainer(container, proxy, {})->describeBackup());
2512+
// For blobstore:// URLs, use invalidVersion to allow describeBackup to write missing version properties
2513+
BackupDescription desc =
2514+
wait(IBackupContainer::openContainer(container, proxy, {})
2515+
->describeBackup(false, isBlobstoreUrl(container) ? invalidVersion : 0));
25052516
if (!desc.maxRestorableVersion.present()) {
25062517
fprintf(stderr, "The specified backup is not restorable to any version.\n");
25072518
throw restore_error();
@@ -2541,7 +2552,9 @@ ACTOR Future<Void> runFastRestoreTool(Database db,
25412552
restoreVersion = dbVersion;
25422553
} else {
25432554
state Reference<IBackupContainer> bc = IBackupContainer::openContainer(container, proxy, {});
2544-
state BackupDescription description = wait(bc->describeBackup());
2555+
// For blobstore:// URLs, use invalidVersion to allow describeBackup to write missing version properties
2556+
state BackupDescription description =
2557+
wait(bc->describeBackup(false, isBlobstoreUrl(container) ? invalidVersion : 0));
25452558

25462559
if (dbVersion <= 0) {
25472560
wait(description.resolveVersionTimes(db));

0 commit comments

Comments
 (0)