From e183a10c8c4d8d1a8b69b596d0c97d7365e1ec86 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Tue, 20 Oct 2020 22:48:53 -0700 Subject: [PATCH] Add "waitForDestUID" flag for abortBackup --- fdbclient/BackupAgent.actor.h | 3 ++- fdbclient/DatabaseBackupAgent.actor.cpp | 10 ++++++---- fdbserver/workloads/BackupToDBCorrectness.actor.cpp | 8 +++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/fdbclient/BackupAgent.actor.h b/fdbclient/BackupAgent.actor.h index 0037541cef..aa7e56f140 100644 --- a/fdbclient/BackupAgent.actor.h +++ b/fdbclient/BackupAgent.actor.h @@ -428,7 +428,8 @@ public: return runRYWTransaction(cx, [=](Reference tr){ return discontinueBackup(tr, tagName); }); } - Future abortBackup(Database cx, Key tagName, bool partial = false, bool abortOldBackup = false, bool dstOnly = false); + Future abortBackup(Database cx, Key tagName, bool partial = false, bool abortOldBackup = false, + bool dstOnly = false, bool waitForDestUID = false); Future getStatus(Database cx, int errorLimit, Key tagName); diff --git a/fdbclient/DatabaseBackupAgent.actor.cpp b/fdbclient/DatabaseBackupAgent.actor.cpp index a829f488bb..13d1567b1c 100644 --- a/fdbclient/DatabaseBackupAgent.actor.cpp +++ b/fdbclient/DatabaseBackupAgent.actor.cpp @@ -2098,7 +2098,8 @@ public: return Void(); } - ACTOR static Future abortBackup(DatabaseBackupAgent* backupAgent, Database cx, Key tagName, bool partial, bool abortOldBackup, bool dstOnly) { + ACTOR static Future abortBackup(DatabaseBackupAgent* backupAgent, Database cx, Key tagName, bool partial, + bool abortOldBackup, bool dstOnly, bool waitForDestUID) { state Reference 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 DatabaseBackupAgent::discontinueBackup(Reference DatabaseBackupAgent::abortBackup(Database cx, Key tagName, bool partial, bool abortOldBackup, bool dstOnly){ - return DatabaseBackupAgentImpl::abortBackup(this, cx, tagName, partial, abortOldBackup, dstOnly); +Future 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 DatabaseBackupAgent::getStatus(Database cx, int errorLimit, Key tagName) { diff --git a/fdbserver/workloads/BackupToDBCorrectness.actor.cpp b/fdbserver/workloads/BackupToDBCorrectness.actor.cpp index 5cba973c16..2f08e2d1bf 100644 --- a/fdbserver/workloads/BackupToDBCorrectness.actor.cpp +++ b/fdbserver/workloads/BackupToDBCorrectness.actor.cpp @@ -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;