fix: latestRestorable was incorrect

This commit is contained in:
Evan Tschannen 2017-12-21 17:09:21 -08:00
parent 5ed080721d
commit 69f7409c37
2 changed files with 16 additions and 4 deletions

View File

@ -677,14 +677,20 @@ public:
return configSpace.pack(LiteralStringRef(__FUNCTION__)); return configSpace.pack(LiteralStringRef(__FUNCTION__));
} }
// The end version of the first complete snapshot
KeyBackedProperty<Version> firstSnapshotEndVersion() {
return configSpace.pack(LiteralStringRef(__FUNCTION__));
}
Future<Optional<Version>> getLatestRestorableVersion(Reference<ReadYourWritesTransaction> tr) { Future<Optional<Version>> getLatestRestorableVersion(Reference<ReadYourWritesTransaction> tr) {
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS); tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
tr->setOption(FDBTransactionOptions::READ_LOCK_AWARE); tr->setOption(FDBTransactionOptions::READ_LOCK_AWARE);
auto &copy = *this; auto &copy = *this;
auto lastLog = latestLogEndVersion().get(tr); auto lastLog = latestLogEndVersion().get(tr);
auto lastSnapshot = latestSnapshotEndVersion().get(tr); auto firstSnapshot = firstSnapshotEndVersion().get(tr);
return map(success(lastLog) && success(lastSnapshot), [=](Void) -> Optional<Version> { return map(success(lastLog) && success(firstSnapshot), [=](Void) -> Optional<Version> {
if(lastLog.get().present() && lastSnapshot.get().present()) { // The latest log greater than the oldest snapshot is the restorable version
if(lastLog.get().present() && firstSnapshot.get().present() && lastLog.get().get() >= firstSnapshot.get().get()) {
return lastLog.get().get(); return lastLog.get().get();
} }
return {}; return {};

View File

@ -1845,10 +1845,16 @@ namespace fileBackup {
state bool stopWhenDone; state bool stopWhenDone;
state EBackupState backupState; state EBackupState backupState;
state Optional<Version> restorableVersion; state Optional<Version> restorableVersion;
state Optional<Version> firstSnapshotEndVersion;
Void _ = wait(store(config.stopWhenDone().getOrThrow(tr), stopWhenDone) Void _ = wait(store(config.stopWhenDone().getOrThrow(tr), stopWhenDone)
&& store(config.stateEnum().getOrThrow(tr), backupState) && store(config.stateEnum().getOrThrow(tr), backupState)
&& store(config.getLatestRestorableVersion(tr), restorableVersion)); && store(config.getLatestRestorableVersion(tr), restorableVersion)
&& store(config.firstSnapshotEndVersion().get(tr), firstSnapshotEndVersion));
if(!firstSnapshotEndVersion.present()) {
config.firstSnapshotEndVersion().set(tr, Params.endVersion().get(task));
}
// If the backup is restorable and the state isn't differential the set state to differential // If the backup is restorable and the state isn't differential the set state to differential
if(restorableVersion.present() && backupState != BackupAgentBase::STATE_DIFFERENTIAL) if(restorableVersion.present() && backupState != BackupAgentBase::STATE_DIFFERENTIAL)