Add "waitForDestUID" flag for abortBackup

This commit is contained in:
Jingyu Zhou 2020-10-20 22:48:53 -07:00
parent 47a9bc9d3d
commit e183a10c8c
3 changed files with 13 additions and 8 deletions

View File

@ -428,7 +428,8 @@ public:
return runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr){ return discontinueBackup(tr, tagName); });
}
Future<Void> abortBackup(Database cx, Key tagName, bool partial = false, bool abortOldBackup = false, bool dstOnly = false);
Future<Void> abortBackup(Database cx, Key tagName, bool partial = false, bool abortOldBackup = false,
bool dstOnly = false, bool waitForDestUID = false);
Future<std::string> getStatus(Database cx, int errorLimit, Key tagName);

View File

@ -2098,7 +2098,8 @@ public:
return Void();
}
ACTOR static Future<Void> abortBackup(DatabaseBackupAgent* backupAgent, Database cx, Key tagName, bool partial, bool abortOldBackup, bool dstOnly) {
ACTOR static Future<Void> abortBackup(DatabaseBackupAgent* backupAgent, Database cx, Key tagName, bool partial,
bool abortOldBackup, bool dstOnly, bool waitForDestUID) {
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
state Key logUidValue, destUidValue;
state UID logUid, destUid;
@ -2125,7 +2126,7 @@ public:
UID destUid = destUidFuture.get();
if (destUid.isValid()) {
destUidValue = BinaryWriter::toValue(destUid, Unversioned());
} else if (destUidValue.size() == 0) {
} else if (destUidValue.size() == 0 && waitForDestUID) {
// Give DR task a chance to update destUid to avoid the problem of
// leftover version key. If we got an commit_unknown_result before,
// reuse the previous destUidValue.
@ -2459,8 +2460,9 @@ Future<Void> DatabaseBackupAgent::discontinueBackup(Reference<ReadYourWritesTran
return DatabaseBackupAgentImpl::discontinueBackup(this, tr, tagName);
}
Future<Void> DatabaseBackupAgent::abortBackup(Database cx, Key tagName, bool partial, bool abortOldBackup, bool dstOnly){
return DatabaseBackupAgentImpl::abortBackup(this, cx, tagName, partial, abortOldBackup, dstOnly);
Future<Void> DatabaseBackupAgent::abortBackup(Database cx, Key tagName, bool partial, bool abortOldBackup, bool dstOnly,
bool waitForDestUID) {
return DatabaseBackupAgentImpl::abortBackup(this, cx, tagName, partial, abortOldBackup, dstOnly, waitForDestUID);
}
Future<std::string> DatabaseBackupAgent::getStatus(Database cx, int errorLimit, Key tagName) {

View File

@ -545,9 +545,11 @@ struct BackupToDBCorrectnessWorkload : TestWorkload {
TraceEvent("BARW_AbortBackupExtra", randomID).detail("BackupTag", printable(self->backupTag));
try {
wait(backupAgent.abortBackup(self->extraDB, self->backupTag));
}
catch (Error& e) {
// This abort can race with submitBackup such that destUID may
// not be set yet. Adding "waitForDestUID" flag to avoid the race.
wait(backupAgent.abortBackup(self->extraDB, self->backupTag, /*partial=*/false,
/*abortOldBackup=*/false, /*dstOnly=*/false, /*waitForDestUID*/ true));
} catch (Error& e) {
TraceEvent("BARW_AbortBackupExtraException", randomID).error(e);
if (e.code() != error_code_backup_unneeded)
throw;