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:
parent
e750682b74
commit
5ed080721d
|
@ -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 © = *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 {};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue