diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index 23a3a021db..61756e5092 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -494,6 +494,7 @@ ProcessData decodeWorkerListValue( ValueRef const& value ) { const KeyRangeRef backupProgressKeys(LiteralStringRef("\xff/backupProgress/"), LiteralStringRef("\xff/backupProgress0")); const KeyRef backupProgressPrefix = backupProgressKeys.begin; +const KeyRef backupStartedKey = LiteralStringRef("\xff/backupStarted"); const Key backupProgressKeyFor(UID workerID) { BinaryWriter wr(Unversioned()); diff --git a/fdbclient/SystemData.h b/fdbclient/SystemData.h index 195e2184c4..2e1d2c5c67 100644 --- a/fdbclient/SystemData.h +++ b/fdbclient/SystemData.h @@ -182,6 +182,9 @@ const Value backupProgressValue(const WorkerBackupStatus& status); UID decodeBackupProgressKey(const KeyRef& key); WorkerBackupStatus decodeBackupProgressValue(const ValueRef& value); +// "\xff/backupStarted" +extern const KeyRef backupStartedKey; + extern const KeyRef coordinatorsKey; extern const KeyRef logsKey; extern const KeyRef minRequiredCommitVersionKey; diff --git a/fdbserver/BackupProgress.actor.cpp b/fdbserver/BackupProgress.actor.cpp index d0ef2ef77d..f4f2577234 100644 --- a/fdbserver/BackupProgress.actor.cpp +++ b/fdbserver/BackupProgress.actor.cpp @@ -20,6 +20,8 @@ void BackupProgress::addBackupStatus(const WorkerBackupStatus& status) { std::map, std::map> BackupProgress::getUnfinishedBackup() { std::map, std::map> toRecruit; + if (!backupStartedValue.present()) return toRecruit; // No active backups + for (const auto& [epoch, info] : epochInfos) { std::set tags = enumerateLogRouterTags(info.logRouterTags); std::map tagVersions; @@ -60,9 +62,11 @@ ACTOR Future getBackupProgress(Database cx, UID dbgid, Reference value = wait(tr.get(backupStartedKey)); Standalone results = wait(tr.getRange(backupProgressKeys, CLIENT_KNOBS->TOO_MANY)); ASSERT(!results.more && results.size() < CLIENT_KNOBS->TOO_MANY); + bStatus->setBackupStartedValue(value); for (auto& it : results) { const UID workerID = decodeBackupProgressKey(it.key); const WorkerBackupStatus status = decodeBackupProgressValue(it.value); @@ -87,6 +91,7 @@ TEST_CASE("/BackupProgress/Unfinished") { const Tag tag1(tagLocalityLogRouter, 0); epochInfos.insert({ epoch1, ILogSystem::EpochTagsVersionsInfo(1, begin1, end1) }); BackupProgress progress(UID(0, 0), epochInfos); + progress.setBackupStartedValue(Optional(LiteralStringRef("1"))); std::map, std::map> unfinished = progress.getUnfinishedBackup(); diff --git a/fdbserver/BackupProgress.actor.h b/fdbserver/BackupProgress.actor.h index 8a0fca2a03..baa3e5554a 100644 --- a/fdbserver/BackupProgress.actor.h +++ b/fdbserver/BackupProgress.actor.h @@ -51,6 +51,11 @@ public: // backup [savedVersion + 1, endVersion) std::map, std::map> getUnfinishedBackup(); + // Set the value for "backupStartedKey" + void setBackupStartedValue(Optional value) { + backupStartedValue = value; + } + void addref() { ReferenceCounted::addref(); } void delref() { ReferenceCounted::delref(); } @@ -73,6 +78,9 @@ private: // progress status for a tag in an epoch due to later epoch trying to fill // the gap. "progress" MUST be iterated in ascending order. std::map> progress; + + // Value of the "backupStartedKey". + Optional backupStartedValue; }; ACTOR Future getBackupProgress(Database cx, UID dbgid, Reference bStatus);