Remove invalid backup status fields

This commit is contained in:
sfc-gh-tclinkenbeard 2021-03-08 15:48:46 -08:00
parent fab8c3f41a
commit f81d4eb6d3
3 changed files with 19 additions and 10 deletions

View File

@ -1473,7 +1473,7 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
state FileBackupAgent fba; state FileBackupAgent fba;
state std::vector<KeyBackedTag> backupTags = wait(getAllBackupTags(tr, snapshot)); state std::vector<KeyBackedTag> backupTags = wait(getAllBackupTags(tr, snapshot));
state std::vector<Future<Version>> tagLastRestorableVersions; state std::vector<Future<Optional<Version>>> tagLastRestorableVersions;
state std::vector<Future<EBackupState>> tagStates; state std::vector<Future<EBackupState>> tagStates;
state std::vector<Future<Reference<IBackupContainer>>> tagContainers; state std::vector<Future<Reference<IBackupContainer>>> tagContainers;
state std::vector<Future<int64_t>> tagRangeBytes; state std::vector<Future<int64_t>> tagRangeBytes;
@ -1505,8 +1505,6 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
int j = 0; int j = 0;
for (KeyBackedTag eachTag : backupTags) { 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(); EBackupState status = tagStates[j].get();
const char *statusText = fba.getStateText(status); const char *statusText = fba.getStateText(status);
@ -1514,8 +1512,13 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
JSONDoc tagRoot = tagsRoot.subDoc(eachTag.tagName); JSONDoc tagRoot = tagsRoot.subDoc(eachTag.tagName);
tagRoot.create("current_container") = tagContainers[j].get()->getURL(); tagRoot.create("current_container") = tagContainers[j].get()->getURL();
tagRoot.create("current_status") = statusText; tagRoot.create("current_status") = statusText;
tagRoot.create("last_restorable_version") = tagLastRestorableVersions[j].get(); if (tagLastRestorableVersions[j].get().present()) {
tagRoot.create("last_restorable_seconds_behind") = last_restorable_seconds_behind; 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") = tagRoot.create("running_backup") =
(status == EBackupState::STATE_RUNNING_DIFFERENTIAL || status == EBackupState::STATE_RUNNING); (status == EBackupState::STATE_RUNNING_DIFFERENTIAL || status == EBackupState::STATE_RUNNING);
tagRoot.create("running_backup_is_restorable") = (status == EBackupState::STATE_RUNNING_DIFFERENTIAL); tagRoot.create("running_backup_is_restorable") = (status == EBackupState::STATE_RUNNING_DIFFERENTIAL);

View File

@ -353,7 +353,8 @@ public:
Future<std::string> getStatus(Database cx, bool showErrors, std::string tagName); Future<std::string> getStatus(Database cx, bool showErrors, std::string tagName);
Future<std::string> getStatusJSON(Database cx, std::string tagName); Future<std::string> getStatusJSON(Database cx, std::string tagName);
Future<Version> getLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName, bool snapshot = false); Future<Optional<Version>> getLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName,
bool snapshot = false);
void setLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName, Version version); void setLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName, Version version);
// stopWhenDone will return when the backup is stopped, if enabled. Otherwise, it // stopWhenDone will return when the backup is stopped, if enabled. Otherwise, it

View File

@ -4465,12 +4465,16 @@ public:
return statusText; return statusText;
} }
ACTOR static Future<Version> getLastRestorable(FileBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, Key tagName, bool snapshot) { ACTOR static Future<Optional<Version>> getLastRestorable(FileBackupAgent* backupAgent,
Reference<ReadYourWritesTransaction> tr, Key tagName,
bool snapshot) {
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr->setOption(FDBTransactionOptions::LOCK_AWARE); tr->setOption(FDBTransactionOptions::LOCK_AWARE);
state Optional<Value> version = wait(tr->get(backupAgent->lastRestorable.pack(tagName), snapshot)); state Optional<Value> version = wait(tr->get(backupAgent->lastRestorable.pack(tagName), snapshot));
return (version.present()) ? BinaryReader::fromStringRef<Version>(version.get(), Unversioned()) : 0; return (version.present())
? Optional<Version>(BinaryReader::fromStringRef<Version>(version.get(), Unversioned()))
: Optional<Version>();
} }
static StringRef read(StringRef& data, int bytes) { static StringRef read(StringRef& data, int bytes) {
@ -4749,7 +4753,8 @@ Future<std::string> FileBackupAgent::getStatusJSON(Database cx, std::string tagN
return FileBackupAgentImpl::getStatusJSON(this, cx, tagName); return FileBackupAgentImpl::getStatusJSON(this, cx, tagName);
} }
Future<Version> FileBackupAgent::getLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName, bool snapshot) { Future<Optional<Version>> FileBackupAgent::getLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName,
bool snapshot) {
return FileBackupAgentImpl::getLastRestorable(this, tr, tagName, snapshot); return FileBackupAgentImpl::getLastRestorable(this, tr, tagName, snapshot);
} }
@ -5023,4 +5028,4 @@ void simulateBlobFailure() {
throw lookup_failed(); throw lookup_failed();
} }
} }
} }