Add atomicParallelRestore to AtomicRestore workload

This commit is contained in:
Meng Xu 2020-03-24 15:51:40 -07:00
parent 01921c3953
commit b173929316
2 changed files with 28 additions and 20 deletions

View File

@ -4569,8 +4569,12 @@ public:
Reference<IBackupContainer> bc = wait(backupConfig.backupContainer().getOrThrow(cx));
TraceEvent("AS_StartRestore");
Version ver = wait( restore(backupAgent, cx, cx, tagName, KeyRef(bc->getURL()), ranges, true, -1, true, addPrefix, removePrefix, true, randomUid) );
TraceEvent("AtomicParallelRestoreStartRestore");
Version targetVersion = -1;
bool locked = true;
wait(submitParallelRestore(cx, tagName, ranges, KeyRef(bc->getURL()), targetVersion, locked));
TraceEvent("AtomicParallelRestoreWaitForRestoreFinish");
wait(parallelRestoreFinish(cx));
return ver;
}
};

View File

@ -79,26 +79,30 @@ struct AtomicRestoreWorkload : TestWorkload {
wait( delay(self->restoreAfter * deterministicRandom()->random01()) );
TraceEvent("AtomicRestore_RestoreStart");
loop {
std::vector<Future<Version>> restores;
if (deterministicRandom()->random01() < 0.5) {
for (auto &range : self->backupRanges)
restores.push_back(backupAgent.atomicRestore(cx, BackupAgentBase::getDefaultTag(), range, StringRef(), StringRef()));
if (deterministicRandom()->random01() < 0.5 && BUGGIFY) { // New fast parallel restore
TraceEvent(SevWarnAlways, "AtomicParallelRestore");
wait(backupAgent.atomicParallelRestore(cx, BackupAgentBase::getDefaultTag(), self->backupRanges, StringRef(), StringRef()));
} else { // Old style restore
loop {
std::vector<Future<Version>> restores;
if (deterministicRandom()->random01() < 0.5) {
for (auto& range : self->backupRanges)
restores.push_back(backupAgent.atomicRestore(cx, BackupAgentBase::getDefaultTag(), range,
StringRef(), StringRef()));
} else {
restores.push_back(backupAgent.atomicRestore(cx, BackupAgentBase::getDefaultTag(),
self->backupRanges, StringRef(), StringRef()));
}
try {
wait(waitForAll(restores));
break;
} catch (Error& e) {
if (e.code() != error_code_backup_unneeded && e.code() != error_code_backup_duplicate) throw;
}
wait(delay(FLOW_KNOBS->PREVENT_FAST_SPIN_DELAY));
}
else {
restores.push_back(backupAgent.atomicRestore(cx, BackupAgentBase::getDefaultTag(), self->backupRanges, StringRef(), StringRef()));
}
try {
wait(waitForAll(restores));
break;
}
catch (Error& e) {
if (e.code() != error_code_backup_unneeded && e.code() != error_code_backup_duplicate)
throw;
}
wait( delay(FLOW_KNOBS->PREVENT_FAST_SPIN_DELAY) );
}
// SOMEDAY: Remove after backup agents can exist quiescently
if (g_simulator.backupAgents == ISimulator::BackupToFile) {
g_simulator.backupAgents = ISimulator::NoBackupAgents;