diff --git a/fdbbackup/backup.actor.cpp b/fdbbackup/backup.actor.cpp index 40948f6808..f0d0dd6ecc 100644 --- a/fdbbackup/backup.actor.cpp +++ b/fdbbackup/backup.actor.cpp @@ -1473,7 +1473,7 @@ ACTOR Future getLayerStatus(Reference tr state FileBackupAgent fba; state std::vector backupTags = wait(getAllBackupTags(tr, snapshot)); - state std::vector> tagLastRestorableVersions; + state std::vector>> tagLastRestorableVersions; state std::vector> tagStates; state std::vector>> tagContainers; state std::vector> tagRangeBytes; @@ -1505,8 +1505,6 @@ ACTOR Future getLayerStatus(Reference tr int j = 0; for (KeyBackedTag eachTag : backupTags) { - Version last_restorable_version = tagLastRestorableVersions[j].get(); - double last_restorable_seconds_behind = ((double)readVer - last_restorable_version) / CLIENT_KNOBS->CORE_VERSIONSPERSECOND; EBackupState status = tagStates[j].get(); const char *statusText = fba.getStateText(status); @@ -1514,8 +1512,13 @@ ACTOR Future getLayerStatus(Reference tr JSONDoc tagRoot = tagsRoot.subDoc(eachTag.tagName); tagRoot.create("current_container") = tagContainers[j].get()->getURL(); tagRoot.create("current_status") = statusText; - tagRoot.create("last_restorable_version") = tagLastRestorableVersions[j].get(); - tagRoot.create("last_restorable_seconds_behind") = last_restorable_seconds_behind; + if (tagLastRestorableVersions[j].get().present()) { + Version last_restorable_version = tagLastRestorableVersions[j].get().get(); + double last_restorable_seconds_behind = + ((double)readVer - last_restorable_version) / CLIENT_KNOBS->CORE_VERSIONSPERSECOND; + tagRoot.create("last_restorable_version") = last_restorable_version; + tagRoot.create("last_restorable_seconds_behind") = last_restorable_seconds_behind; + } tagRoot.create("running_backup") = (status == EBackupState::STATE_RUNNING_DIFFERENTIAL || status == EBackupState::STATE_RUNNING); tagRoot.create("running_backup_is_restorable") = (status == EBackupState::STATE_RUNNING_DIFFERENTIAL); diff --git a/fdbclient/BackupAgent.actor.h b/fdbclient/BackupAgent.actor.h index e3309a3f29..c7cfb0b64b 100644 --- a/fdbclient/BackupAgent.actor.h +++ b/fdbclient/BackupAgent.actor.h @@ -353,7 +353,8 @@ public: Future getStatus(Database cx, bool showErrors, std::string tagName); Future getStatusJSON(Database cx, std::string tagName); - Future getLastRestorable(Reference tr, Key tagName, bool snapshot = false); + Future> getLastRestorable(Reference tr, Key tagName, + bool snapshot = false); void setLastRestorable(Reference tr, Key tagName, Version version); // stopWhenDone will return when the backup is stopped, if enabled. Otherwise, it diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index c7eb060e6e..a1bc9b9849 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -4465,12 +4465,16 @@ public: return statusText; } - ACTOR static Future getLastRestorable(FileBackupAgent* backupAgent, Reference tr, Key tagName, bool snapshot) { + ACTOR static Future> getLastRestorable(FileBackupAgent* backupAgent, + Reference tr, Key tagName, + bool snapshot) { tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::LOCK_AWARE); state Optional version = wait(tr->get(backupAgent->lastRestorable.pack(tagName), snapshot)); - return (version.present()) ? BinaryReader::fromStringRef(version.get(), Unversioned()) : 0; + return (version.present()) + ? Optional(BinaryReader::fromStringRef(version.get(), Unversioned())) + : Optional(); } static StringRef read(StringRef& data, int bytes) { @@ -4749,7 +4753,8 @@ Future FileBackupAgent::getStatusJSON(Database cx, std::string tagN return FileBackupAgentImpl::getStatusJSON(this, cx, tagName); } -Future FileBackupAgent::getLastRestorable(Reference tr, Key tagName, bool snapshot) { +Future> FileBackupAgent::getLastRestorable(Reference tr, Key tagName, + bool snapshot) { return FileBackupAgentImpl::getLastRestorable(this, tr, tagName, snapshot); } @@ -5023,4 +5028,4 @@ void simulateBlobFailure() { throw lookup_failed(); } } -} \ No newline at end of file +}