fix: atomic restore must wait for the restorable version is greater than the lock version

fix: latestRestorableVersion calculation was wrong
This commit is contained in:
Evan Tschannen 2017-12-21 15:45:10 -08:00
parent e750682b74
commit 5ed080721d
2 changed files with 22 additions and 3 deletions

View File

@ -678,13 +678,15 @@ public:
}
Future<Optional<Version>> getLatestRestorableVersion(Reference<ReadYourWritesTransaction> tr) {
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
tr->setOption(FDBTransactionOptions::READ_LOCK_AWARE);
auto &copy = *this;
auto lastLog = latestLogEndVersion().get(tr);
auto lastSnapshot = latestSnapshotEndVersion().get(tr);
return map(success(lastLog) && success(lastSnapshot), [=](Void) -> Optional<Version> {
if(lastLog.get().present() && lastSnapshot.get().present()
&& lastLog.get().get() >= lastSnapshot.get().get())
return lastLog.get().get();
if(lastLog.get().present() && lastSnapshot.get().present()) {
return lastLog.get().get();
}
return {};
});
}

View File

@ -3472,12 +3472,29 @@ public:
Void _ = wait( lockDatabase(&tr, randomUid) );
Void _ = wait(tr.commit());
commitVersion = tr.getCommittedVersion();
TraceEvent("AS_locked").detail("commitVer", commitVersion);
break;
} catch( Error &e ) {
Void _ = wait(tr.onError(e));
}
}
ryw_tr->reset();
loop {
try {
Optional<Version> restoreVersion = wait( backupConfig.getLatestRestorableVersion(ryw_tr) );
if(restoreVersion.present() && restoreVersion.get() >= commitVersion) {
TraceEvent("AS_restoreVersion").detail("restoreVer", restoreVersion.get());
break;
} else {
ryw_tr->reset();
Void _ = wait(delay(0.2));
}
} catch( Error &e ) {
Void _ = wait( ryw_tr->onError(e) );
}
}
ryw_tr->reset();
loop {
try {