Merge branch 'master' of https://github.com/apple/foundationdb into jfu-ibackup-test-timeout
This commit is contained in:
commit
d0b8f7b1e3
|
@ -1449,7 +1449,7 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
|
|||
for (KeyBackedTag eachTag : backupTags) {
|
||||
Version last_restorable_version = tagLastRestorableVersions[j].get();
|
||||
double last_restorable_seconds_behind = ((double)readVer - last_restorable_version) / CLIENT_KNOBS->CORE_VERSIONSPERSECOND;
|
||||
BackupAgentBase::enumState status = (BackupAgentBase::enumState)tagStates[j].get();
|
||||
EBackupState status = tagStates[j].get();
|
||||
const char *statusText = fba.getStateText(status);
|
||||
|
||||
// The object for this backup tag inside this instance's subdocument
|
||||
|
@ -1458,8 +1458,9 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
|
|||
tagRoot.create("current_status") = statusText;
|
||||
tagRoot.create("last_restorable_version") = tagLastRestorableVersions[j].get();
|
||||
tagRoot.create("last_restorable_seconds_behind") = last_restorable_seconds_behind;
|
||||
tagRoot.create("running_backup") = (status == BackupAgentBase::STATE_RUNNING_DIFFERENTIAL || status == BackupAgentBase::STATE_RUNNING);
|
||||
tagRoot.create("running_backup_is_restorable") = (status == BackupAgentBase::STATE_RUNNING_DIFFERENTIAL);
|
||||
tagRoot.create("running_backup") =
|
||||
(status == EBackupState::STATE_RUNNING_DIFFERENTIAL || status == EBackupState::STATE_RUNNING);
|
||||
tagRoot.create("running_backup_is_restorable") = (status == EBackupState::STATE_RUNNING_DIFFERENTIAL);
|
||||
tagRoot.create("range_bytes_written") = tagRangeBytes[j].get();
|
||||
tagRoot.create("mutation_log_bytes_written") = tagLogBytes[j].get();
|
||||
tagRoot.create("mutation_stream_id") = backupTagUids[j].toString();
|
||||
|
@ -1474,7 +1475,7 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
|
|||
tr2->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
state Standalone<RangeResultRef> tagNames = wait(tr2->getRange(dba.tagNames.range(), 10000, snapshot));
|
||||
state std::vector<Future<Optional<Key>>> backupVersion;
|
||||
state std::vector<Future<int>> backupStatus;
|
||||
state std::vector<Future<EBackupState>> backupStatus;
|
||||
state std::vector<Future<int64_t>> tagRangeBytesDR;
|
||||
state std::vector<Future<int64_t>> tagLogBytesDR;
|
||||
state Future<Optional<Value>> fDRPaused = tr->get(dba.taskBucket->getPauseKey(), snapshot);
|
||||
|
@ -1499,11 +1500,12 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
|
|||
for (int i = 0; i < tagNames.size(); i++) {
|
||||
std::string tagName = dba.sourceTagNames.unpack(tagNames[i].key).getString(0).toString();
|
||||
|
||||
BackupAgentBase::enumState status = (BackupAgentBase::enumState)backupStatus[i].get();
|
||||
auto status = backupStatus[i].get();
|
||||
|
||||
JSONDoc tagRoot = tagsRoot.create(tagName);
|
||||
tagRoot.create("running_backup") = (status == BackupAgentBase::STATE_RUNNING_DIFFERENTIAL || status == BackupAgentBase::STATE_RUNNING);
|
||||
tagRoot.create("running_backup_is_restorable") = (status == BackupAgentBase::STATE_RUNNING_DIFFERENTIAL);
|
||||
tagRoot.create("running_backup") =
|
||||
(status == EBackupState::STATE_RUNNING_DIFFERENTIAL || status == EBackupState::STATE_RUNNING);
|
||||
tagRoot.create("running_backup_is_restorable") = (status == EBackupState::STATE_RUNNING_DIFFERENTIAL);
|
||||
tagRoot.create("range_bytes_written") = tagRangeBytesDR[i].get();
|
||||
tagRoot.create("mutation_log_bytes_written") = tagLogBytesDR[i].get();
|
||||
tagRoot.create("mutation_stream_id") = drTagUids[i].toString();
|
||||
|
@ -1787,7 +1789,7 @@ ACTOR Future<Void> submitBackup(Database db, std::string url, int snapshotInterv
|
|||
EBackupState backupStatus = wait(config.stateEnum().getOrThrow(db));
|
||||
|
||||
// Throw error if a backup is currently running until we support parallel backups
|
||||
if (BackupAgentBase::isRunnable((BackupAgentBase::enumState)backupStatus)) {
|
||||
if (BackupAgentBase::isRunnable(backupStatus)) {
|
||||
throw backup_duplicate();
|
||||
}
|
||||
}
|
||||
|
@ -2012,10 +2014,10 @@ ACTOR Future<Void> waitBackup(Database db, std::string tagName, bool stopWhenDon
|
|||
{
|
||||
state FileBackupAgent backupAgent;
|
||||
|
||||
int status = wait(backupAgent.waitBackup(db, tagName, stopWhenDone));
|
||||
EBackupState status = wait(backupAgent.waitBackup(db, tagName, stopWhenDone));
|
||||
|
||||
printf("The backup on tag `%s' %s.\n", printable(StringRef(tagName)).c_str(),
|
||||
BackupAgentBase::getStateText((BackupAgentBase::enumState) status));
|
||||
BackupAgentBase::getStateText(status));
|
||||
}
|
||||
catch (Error& e) {
|
||||
if(e.code() == error_code_actor_cancelled)
|
||||
|
|
|
@ -46,13 +46,15 @@ public:
|
|||
return "YYYY/MM/DD.HH:MI:SS[+/-]HHMM";
|
||||
}
|
||||
|
||||
// Type of program being executed
|
||||
enum enumActionResult {
|
||||
RESULT_SUCCESSFUL = 0, RESULT_ERRORED = 1, RESULT_DUPLICATE = 2, RESULT_UNNEEDED = 3
|
||||
};
|
||||
|
||||
enum enumState {
|
||||
STATE_ERRORED = 0, STATE_SUBMITTED = 1, STATE_RUNNING = 2, STATE_RUNNING_DIFFERENTIAL = 3, STATE_COMPLETED = 4, STATE_NEVERRAN = 5, STATE_ABORTED = 6, STATE_PARTIALLY_ABORTED = 7
|
||||
enum class EnumState {
|
||||
STATE_ERRORED = 0,
|
||||
STATE_SUBMITTED = 1,
|
||||
STATE_RUNNING = 2,
|
||||
STATE_RUNNING_DIFFERENTIAL = 3,
|
||||
STATE_COMPLETED = 4,
|
||||
STATE_NEVERRAN = 5,
|
||||
STATE_ABORTED = 6,
|
||||
STATE_PARTIALLY_ABORTED = 7
|
||||
};
|
||||
|
||||
static const Key keyFolderId;
|
||||
|
@ -85,70 +87,68 @@ public:
|
|||
static const int logHeaderSize;
|
||||
|
||||
// Convert the status text to an enumerated value
|
||||
static enumState getState(std::string stateText)
|
||||
{
|
||||
enumState enState = STATE_ERRORED;
|
||||
static EnumState getState(std::string stateText) {
|
||||
auto enState = EnumState::STATE_ERRORED;
|
||||
|
||||
if (stateText.empty()) {
|
||||
enState = STATE_NEVERRAN;
|
||||
enState = EnumState::STATE_NEVERRAN;
|
||||
}
|
||||
|
||||
else if (!stateText.compare("has been submitted")) {
|
||||
enState = STATE_SUBMITTED;
|
||||
enState = EnumState::STATE_SUBMITTED;
|
||||
}
|
||||
|
||||
else if (!stateText.compare("has been started")) {
|
||||
enState = STATE_RUNNING;
|
||||
enState = EnumState::STATE_RUNNING;
|
||||
}
|
||||
|
||||
else if (!stateText.compare("is differential")) {
|
||||
enState = STATE_RUNNING_DIFFERENTIAL;
|
||||
enState = EnumState::STATE_RUNNING_DIFFERENTIAL;
|
||||
}
|
||||
|
||||
else if (!stateText.compare("has been completed")) {
|
||||
enState = STATE_COMPLETED;
|
||||
enState = EnumState::STATE_COMPLETED;
|
||||
}
|
||||
|
||||
else if (!stateText.compare("has been aborted")) {
|
||||
enState = STATE_ABORTED;
|
||||
enState = EnumState::STATE_ABORTED;
|
||||
}
|
||||
|
||||
else if (!stateText.compare("has been partially aborted")) {
|
||||
enState = STATE_PARTIALLY_ABORTED;
|
||||
enState = EnumState::STATE_PARTIALLY_ABORTED;
|
||||
}
|
||||
|
||||
return enState;
|
||||
}
|
||||
|
||||
// Convert the status enum to a text description
|
||||
static const char* getStateText(enumState enState)
|
||||
{
|
||||
static const char* getStateText(EnumState enState) {
|
||||
const char* stateText;
|
||||
|
||||
switch (enState)
|
||||
{
|
||||
case STATE_ERRORED:
|
||||
case EnumState::STATE_ERRORED:
|
||||
stateText = "has errored";
|
||||
break;
|
||||
case STATE_NEVERRAN:
|
||||
case EnumState::STATE_NEVERRAN:
|
||||
stateText = "has never been started";
|
||||
break;
|
||||
case STATE_SUBMITTED:
|
||||
case EnumState::STATE_SUBMITTED:
|
||||
stateText = "has been submitted";
|
||||
break;
|
||||
case STATE_RUNNING:
|
||||
case EnumState::STATE_RUNNING:
|
||||
stateText = "has been started";
|
||||
break;
|
||||
case STATE_RUNNING_DIFFERENTIAL:
|
||||
case EnumState::STATE_RUNNING_DIFFERENTIAL:
|
||||
stateText = "is differential";
|
||||
break;
|
||||
case STATE_COMPLETED:
|
||||
case EnumState::STATE_COMPLETED:
|
||||
stateText = "has been completed";
|
||||
break;
|
||||
case STATE_ABORTED:
|
||||
case EnumState::STATE_ABORTED:
|
||||
stateText = "has been aborted";
|
||||
break;
|
||||
case STATE_PARTIALLY_ABORTED:
|
||||
case EnumState::STATE_PARTIALLY_ABORTED:
|
||||
stateText = "has been partially aborted";
|
||||
break;
|
||||
default:
|
||||
|
@ -160,34 +160,33 @@ public:
|
|||
}
|
||||
|
||||
// Convert the status enum to a name
|
||||
static const char* getStateName(enumState enState)
|
||||
{
|
||||
static const char* getStateName(EnumState enState) {
|
||||
const char* s;
|
||||
|
||||
switch (enState)
|
||||
{
|
||||
case STATE_ERRORED:
|
||||
case EnumState::STATE_ERRORED:
|
||||
s = "Errored";
|
||||
break;
|
||||
case STATE_NEVERRAN:
|
||||
case EnumState::STATE_NEVERRAN:
|
||||
s = "NeverRan";
|
||||
break;
|
||||
case STATE_SUBMITTED:
|
||||
case EnumState::STATE_SUBMITTED:
|
||||
s = "Submitted";
|
||||
break;
|
||||
case STATE_RUNNING:
|
||||
case EnumState::STATE_RUNNING:
|
||||
s = "Running";
|
||||
break;
|
||||
case STATE_RUNNING_DIFFERENTIAL:
|
||||
case EnumState::STATE_RUNNING_DIFFERENTIAL:
|
||||
s = "RunningDifferentially";
|
||||
break;
|
||||
case STATE_COMPLETED:
|
||||
case EnumState::STATE_COMPLETED:
|
||||
s = "Completed";
|
||||
break;
|
||||
case STATE_ABORTED:
|
||||
case EnumState::STATE_ABORTED:
|
||||
s = "Aborted";
|
||||
break;
|
||||
case STATE_PARTIALLY_ABORTED:
|
||||
case EnumState::STATE_PARTIALLY_ABORTED:
|
||||
s = "Aborting";
|
||||
break;
|
||||
default:
|
||||
|
@ -199,16 +198,15 @@ public:
|
|||
}
|
||||
|
||||
// Determine if the specified state is runnable
|
||||
static bool isRunnable(enumState enState)
|
||||
{
|
||||
static bool isRunnable(EnumState enState) {
|
||||
bool isRunnable = false;
|
||||
|
||||
switch (enState)
|
||||
{
|
||||
case STATE_SUBMITTED:
|
||||
case STATE_RUNNING:
|
||||
case STATE_RUNNING_DIFFERENTIAL:
|
||||
case STATE_PARTIALLY_ABORTED:
|
||||
case EnumState::STATE_SUBMITTED:
|
||||
case EnumState::STATE_RUNNING:
|
||||
case EnumState::STATE_RUNNING_DIFFERENTIAL:
|
||||
case EnumState::STATE_PARTIALLY_ABORTED:
|
||||
isRunnable = true;
|
||||
break;
|
||||
default:
|
||||
|
@ -359,7 +357,8 @@ public:
|
|||
|
||||
// stopWhenDone will return when the backup is stopped, if enabled. Otherwise, it
|
||||
// will return when the backup directory is restorable.
|
||||
Future<int> waitBackup(Database cx, std::string tagName, bool stopWhenDone = true, Reference<IBackupContainer> *pContainer = nullptr, UID *pUID = nullptr);
|
||||
Future<EnumState> waitBackup(Database cx, std::string tagName, bool stopWhenDone = true,
|
||||
Reference<IBackupContainer>* pContainer = nullptr, UID* pUID = nullptr);
|
||||
|
||||
static const Key keyLastRestorable;
|
||||
|
||||
|
@ -432,8 +431,8 @@ public:
|
|||
|
||||
Future<std::string> getStatus(Database cx, int errorLimit, Key tagName);
|
||||
|
||||
Future<int> getStateValue(Reference<ReadYourWritesTransaction> tr, UID logUid, bool snapshot = false);
|
||||
Future<int> getStateValue(Database cx, UID logUid) {
|
||||
Future<EnumState> getStateValue(Reference<ReadYourWritesTransaction> tr, UID logUid, bool snapshot = false);
|
||||
Future<EnumState> getStateValue(Database cx, UID logUid) {
|
||||
return runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr){ return getStateValue(tr, logUid); });
|
||||
}
|
||||
|
||||
|
@ -452,8 +451,8 @@ public:
|
|||
|
||||
// stopWhenDone will return when the backup is stopped, if enabled. Otherwise, it
|
||||
// will return when the backup directory is restorable.
|
||||
Future<int> waitBackup(Database cx, Key tagName, bool stopWhenDone = true);
|
||||
Future<int> waitSubmitted(Database cx, Key tagName);
|
||||
Future<EnumState> waitBackup(Database cx, Key tagName, bool stopWhenDone = true);
|
||||
Future<EnumState> waitSubmitted(Database cx, Key tagName);
|
||||
Future<Void> waitUpgradeToLatestDrVersion(Database cx, Key tagName);
|
||||
|
||||
static const Key keyAddPrefix;
|
||||
|
@ -522,9 +521,15 @@ ACTOR Future<Void> applyMutations(Database cx, Key uid, Key addPrefix, Key remov
|
|||
NotifiedVersion* committedVersion, Reference<KeyRangeMap<Version>> keyVersion);
|
||||
ACTOR Future<Void> cleanupBackup(Database cx, bool deleteData);
|
||||
|
||||
typedef BackupAgentBase::enumState EBackupState;
|
||||
template<> inline Tuple Codec<EBackupState>::pack(EBackupState const &val) { return Tuple().append(val); }
|
||||
template<> inline EBackupState Codec<EBackupState>::unpack(Tuple const &val) { return (EBackupState)val.getInt(0); }
|
||||
using EBackupState = BackupAgentBase::EnumState;
|
||||
template <>
|
||||
inline Tuple Codec<EBackupState>::pack(EBackupState const& val) {
|
||||
return Tuple().append(static_cast<int>(val));
|
||||
}
|
||||
template <>
|
||||
inline EBackupState Codec<EBackupState>::unpack(Tuple const& val) {
|
||||
return static_cast<EBackupState>(val.getInt(0));
|
||||
}
|
||||
|
||||
// Key backed tags are a single-key slice of the TagUidMap, defined below.
|
||||
// The Value type of the key is a UidAndAbortedFlagT which is a pair of {UID, aborted_flag}
|
||||
|
|
|
@ -965,9 +965,10 @@ namespace dbBackup {
|
|||
tr->clear(KeyRangeRef(logsPath, strinc(logsPath)));
|
||||
|
||||
tr->clear(conf.range());
|
||||
tr->set(states.pack(DatabaseBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_COMPLETED)));
|
||||
tr->set(states.pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(BackupAgentBase::getStateText(EBackupState::STATE_COMPLETED)));
|
||||
|
||||
wait(taskBucket->finish(tr, task));
|
||||
wait(taskBucket->finish(tr, task));
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
@ -1449,9 +1450,10 @@ namespace dbBackup {
|
|||
try {
|
||||
tr.setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
tr.addReadConflictRange(singleKeyRange(sourceStates.pack(DatabaseBackupAgent::keyStateStatus)));
|
||||
tr.set(sourceStates.pack(DatabaseBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_RUNNING_DIFFERENTIAL)));
|
||||
tr.set(sourceStates.pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(BackupAgentBase::getStateText(EBackupState::STATE_RUNNING_DIFFERENTIAL)));
|
||||
|
||||
Key versionKey = task->params[DatabaseBackupAgent::keyConfigLogUid].withPrefix(task->params[BackupAgentBase::destUid]).withPrefix(backupLatestVersionsPrefix);
|
||||
Key versionKey = task->params[DatabaseBackupAgent::keyConfigLogUid].withPrefix(task->params[BackupAgentBase::destUid]).withPrefix(backupLatestVersionsPrefix);
|
||||
Optional<Key> prevBeginVersion = wait(tr.get(versionKey));
|
||||
if (!prevBeginVersion.present()) {
|
||||
return Void();
|
||||
|
@ -1489,9 +1491,10 @@ namespace dbBackup {
|
|||
wait(success(FinishedFullBackupTaskFunc::addTask(tr, taskBucket, task, TaskCompletionKey::noSignal())));
|
||||
}
|
||||
else { // Start the writing of logs, if differential
|
||||
tr->set(states.pack(DatabaseBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_RUNNING_DIFFERENTIAL)));
|
||||
tr->set(states.pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(BackupAgentBase::getStateText(EBackupState::STATE_RUNNING_DIFFERENTIAL)));
|
||||
|
||||
allPartsDone = futureBucket->future(tr);
|
||||
allPartsDone = futureBucket->future(tr);
|
||||
|
||||
Version prevBeginVersion = BinaryReader::fromStringRef<Version>(task->params[DatabaseBackupAgent::keyPrevBeginVersion], Unversioned());
|
||||
wait(success(CopyDiffLogsTaskFunc::addTask(tr, taskBucket, task, prevBeginVersion, restoreVersion, TaskCompletionKey::joinWith(allPartsDone))));
|
||||
|
@ -1623,9 +1626,10 @@ namespace dbBackup {
|
|||
|
||||
srcTr2->set( Subspace(databaseBackupPrefixRange.begin).get(BackupAgentBase::keySourceTagName).pack(task->params[BackupAgentBase::keyTagName]), logUidValue );
|
||||
srcTr2->set( sourceStates.pack(DatabaseBackupAgent::keyFolderId), task->params[DatabaseBackupAgent::keyFolderId] );
|
||||
srcTr2->set( sourceStates.pack(DatabaseBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_RUNNING)));
|
||||
srcTr2->set(sourceStates.pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(BackupAgentBase::getStateText(EBackupState::STATE_RUNNING)));
|
||||
|
||||
state Key destPath = destUidValue.withPrefix(backupLogKeys.begin);
|
||||
state Key destPath = destUidValue.withPrefix(backupLogKeys.begin);
|
||||
// Start logging the mutations for the specified ranges of the tag
|
||||
for (auto &backupRange : backupRanges) {
|
||||
srcTr2->set(logRangesEncodeKey(backupRange.begin, BinaryReader::fromStringRef<UID>(destUidValue, Unversioned())), logRangesEncodeValue(backupRange.end, destPath));
|
||||
|
@ -1666,9 +1670,10 @@ namespace dbBackup {
|
|||
|
||||
tr->set(logUidValue.withPrefix(applyMutationsBeginRange.begin), BinaryWriter::toValue(beginVersion, Unversioned()));
|
||||
tr->set(logUidValue.withPrefix(applyMutationsEndRange.begin), BinaryWriter::toValue(beginVersion, Unversioned()));
|
||||
tr->set(states.pack(DatabaseBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_RUNNING)));
|
||||
tr->set(states.pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(BackupAgentBase::getStateText(EBackupState::STATE_RUNNING)));
|
||||
|
||||
state Reference<TaskFuture> kvBackupRangeComplete = futureBucket->future(tr);
|
||||
state Reference<TaskFuture> kvBackupRangeComplete = futureBucket->future(tr);
|
||||
state Reference<TaskFuture> kvBackupComplete = futureBucket->future(tr);
|
||||
state int rangeCount = 0;
|
||||
|
||||
|
@ -1851,7 +1856,8 @@ public:
|
|||
}
|
||||
|
||||
// This method will return the final status of the backup
|
||||
ACTOR static Future<int> waitBackup(DatabaseBackupAgent* backupAgent, Database cx, Key tagName, bool stopWhenDone) {
|
||||
ACTOR static Future<EBackupState> waitBackup(DatabaseBackupAgent* backupAgent, Database cx, Key tagName,
|
||||
bool stopWhenDone) {
|
||||
state std::string backTrace;
|
||||
state UID logUid = wait(backupAgent->getLogUid(cx, tagName));
|
||||
state Key statusKey = backupAgent->states.get(BinaryWriter::toValue(logUid, Unversioned())).pack(DatabaseBackupAgent::keyStateStatus);
|
||||
|
@ -1862,15 +1868,15 @@ public:
|
|||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
|
||||
try {
|
||||
state int status = wait(backupAgent->getStateValue(tr, logUid));
|
||||
state EBackupState status = wait(backupAgent->getStateValue(tr, logUid));
|
||||
|
||||
// Break, if no longer runnable
|
||||
if (!DatabaseBackupAgent::isRunnable((BackupAgentBase::enumState)status) || BackupAgentBase::STATE_PARTIALLY_ABORTED == status) {
|
||||
if (!DatabaseBackupAgent::isRunnable(status) || EBackupState::STATE_PARTIALLY_ABORTED == status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
// Break, if in differential mode (restorable) and stopWhenDone is not enabled
|
||||
if ((!stopWhenDone) && (BackupAgentBase::STATE_RUNNING_DIFFERENTIAL == status)) {
|
||||
if ((!stopWhenDone) && (EBackupState::STATE_RUNNING_DIFFERENTIAL == status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -1885,7 +1891,7 @@ public:
|
|||
}
|
||||
|
||||
// This method will return the final status of the backup
|
||||
ACTOR static Future<int> waitSubmitted(DatabaseBackupAgent* backupAgent, Database cx, Key tagName) {
|
||||
ACTOR static Future<EBackupState> waitSubmitted(DatabaseBackupAgent* backupAgent, Database cx, Key tagName) {
|
||||
state UID logUid = wait(backupAgent->getLogUid(cx, tagName));
|
||||
state Key statusKey = backupAgent->states.get(BinaryWriter::toValue(logUid, Unversioned())).pack(DatabaseBackupAgent::keyStateStatus);
|
||||
|
||||
|
@ -1895,10 +1901,10 @@ public:
|
|||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
|
||||
try {
|
||||
state int status = wait(backupAgent->getStateValue(tr, logUid));
|
||||
state EBackupState status = wait(backupAgent->getStateValue(tr, logUid));
|
||||
|
||||
// Break, if no longer runnable
|
||||
if( BackupAgentBase::STATE_SUBMITTED != status) {
|
||||
if (EBackupState::STATE_SUBMITTED != status) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -1924,9 +1930,9 @@ public:
|
|||
tr->setOption(FDBTransactionOptions::COMMIT_ON_FIRST_PROXY);
|
||||
|
||||
// We will use the global status for now to ensure that multiple backups do not start place with different tags
|
||||
state int status = wait(backupAgent->getStateValue(tr, logUidCurrent));
|
||||
state EBackupState status = wait(backupAgent->getStateValue(tr, logUidCurrent));
|
||||
|
||||
if (DatabaseBackupAgent::isRunnable((BackupAgentBase::enumState)status)) {
|
||||
if (DatabaseBackupAgent::isRunnable(status)) {
|
||||
throw backup_duplicate();
|
||||
}
|
||||
|
||||
|
@ -1987,7 +1993,8 @@ public:
|
|||
tr->set(backupAgent->config.get(logUidValue).pack(DatabaseBackupAgent::keyFolderId), backupUid);
|
||||
tr->set(backupAgent->states.get(logUidValue).pack(DatabaseBackupAgent::keyFolderId), backupUid); // written to config and states because it's also used by abort
|
||||
tr->set(backupAgent->config.get(logUidValue).pack(DatabaseBackupAgent::keyConfigBackupRanges), BinaryWriter::toValue(backupRanges, IncludeVersion(ProtocolVersion::withDRBackupRanges())));
|
||||
tr->set(backupAgent->states.get(logUidValue).pack(DatabaseBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_SUBMITTED)));
|
||||
tr->set(backupAgent->states.get(logUidValue).pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(BackupAgentBase::getStateText(EBackupState::STATE_SUBMITTED)));
|
||||
if (stopWhenDone) {
|
||||
tr->set(backupAgent->config.get(logUidValue).pack(DatabaseBackupAgent::keyConfigStopWhenDoneKey), StringRef());
|
||||
}
|
||||
|
@ -2033,10 +2040,10 @@ public:
|
|||
ACTOR static Future<Void> atomicSwitchover(DatabaseBackupAgent* backupAgent, Database dest, Key tagName, Standalone<VectorRef<KeyRangeRef>> backupRanges, Key addPrefix, Key removePrefix, bool forceAction) {
|
||||
state DatabaseBackupAgent drAgent(dest);
|
||||
state UID destlogUid = wait(backupAgent->getLogUid(dest, tagName));
|
||||
state int status = wait(backupAgent->getStateValue(dest, destlogUid));
|
||||
state EBackupState status = wait(backupAgent->getStateValue(dest, destlogUid));
|
||||
|
||||
TraceEvent("DBA_SwitchoverStart").detail("Status", status);
|
||||
if (status != BackupAgentBase::STATE_RUNNING_DIFFERENTIAL && status != BackupAgentBase::STATE_COMPLETED) {
|
||||
if (status != EBackupState::STATE_RUNNING_DIFFERENTIAL && status != EBackupState::STATE_COMPLETED) {
|
||||
throw backup_duplicate();
|
||||
}
|
||||
|
||||
|
@ -2153,10 +2160,10 @@ public:
|
|||
ACTOR static Future<Void> discontinueBackup(DatabaseBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, Key tagName) {
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
state UID logUid = wait(backupAgent->getLogUid(tr, tagName));
|
||||
state int status = wait(backupAgent->getStateValue(tr, logUid));
|
||||
state EBackupState status = wait(backupAgent->getStateValue(tr, logUid));
|
||||
|
||||
TraceEvent("DBA_Discontinue").detail("Status", status);
|
||||
if (!DatabaseBackupAgent::isRunnable((BackupAgentBase::enumState)status)) {
|
||||
if (!DatabaseBackupAgent::isRunnable(status)) {
|
||||
throw backup_unneeded();
|
||||
}
|
||||
|
||||
|
@ -2189,7 +2196,7 @@ public:
|
|||
logUid = _logUid;
|
||||
logUidValue = BinaryWriter::toValue(logUid, Unversioned());
|
||||
|
||||
state Future<int> statusFuture= backupAgent->getStateValue(tr, logUid);
|
||||
state Future<EBackupState> statusFuture = backupAgent->getStateValue(tr, logUid);
|
||||
state Future<UID> destUidFuture = backupAgent->getDestUid(tr, logUid);
|
||||
wait(success(statusFuture) && success(destUidFuture));
|
||||
|
||||
|
@ -2197,8 +2204,8 @@ public:
|
|||
if (destUid.isValid()) {
|
||||
destUidValue = BinaryWriter::toValue(destUid, Unversioned());
|
||||
}
|
||||
int status = statusFuture.get();
|
||||
if (!backupAgent->isRunnable((BackupAgentBase::enumState)status)) {
|
||||
EBackupState status = statusFuture.get();
|
||||
if (!backupAgent->isRunnable(status)) {
|
||||
throw backup_unneeded();
|
||||
}
|
||||
|
||||
|
@ -2213,7 +2220,8 @@ public:
|
|||
|
||||
tr->clear(prefixRange(logUidValue.withPrefix(applyLogKeys.begin)));
|
||||
|
||||
tr->set(StringRef(backupAgent->states.get(logUidValue).pack(DatabaseBackupAgent::keyStateStatus)), StringRef(DatabaseBackupAgent::getStateText(BackupAgentBase::STATE_PARTIALLY_ABORTED)));
|
||||
tr->set(StringRef(backupAgent->states.get(logUidValue).pack(DatabaseBackupAgent::keyStateStatus)),
|
||||
StringRef(DatabaseBackupAgent::getStateText(EBackupState::STATE_PARTIALLY_ABORTED)));
|
||||
|
||||
wait(tr->commit());
|
||||
TraceEvent("DBA_Abort").detail("CommitVersion", tr->getCommittedVersion());
|
||||
|
@ -2286,7 +2294,8 @@ public:
|
|||
}
|
||||
|
||||
if (abortOldBackup) {
|
||||
srcTr->set( backupAgent->sourceStates.pack(DatabaseBackupAgent::keyStateStatus), StringRef(BackupAgentBase::getStateText(BackupAgentBase::STATE_ABORTED) ));
|
||||
srcTr->set(backupAgent->sourceStates.pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(BackupAgentBase::getStateText(EBackupState::STATE_ABORTED)));
|
||||
srcTr->set( backupAgent->sourceStates.get(logUidValue).pack(DatabaseBackupAgent::keyFolderId), backupUid );
|
||||
srcTr->clear(prefixRange(logUidValue.withPrefix(backupLogKeys.begin)));
|
||||
srcTr->clear(prefixRange(logUidValue.withPrefix(logRangesRange.begin)));
|
||||
|
@ -2307,7 +2316,8 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
srcTr->set( backupAgent->sourceStates.pack(DatabaseBackupAgent::keyStateStatus), StringRef(DatabaseBackupAgent::getStateText(BackupAgentBase::STATE_PARTIALLY_ABORTED) ));
|
||||
srcTr->set(backupAgent->sourceStates.pack(DatabaseBackupAgent::keyStateStatus),
|
||||
StringRef(DatabaseBackupAgent::getStateText(EBackupState::STATE_PARTIALLY_ABORTED)));
|
||||
srcTr->set( backupAgent->sourceStates.get(logUidValue).pack(DatabaseBackupAgent::keyFolderId), backupUid );
|
||||
|
||||
wait( eraseLogData(srcTr, logUidValue, destUidValue) || partialTimeout );
|
||||
|
@ -2341,7 +2351,8 @@ public:
|
|||
return Void();
|
||||
}
|
||||
|
||||
tr->set(StringRef(backupAgent->states.get(logUidValue).pack(DatabaseBackupAgent::keyStateStatus)), StringRef(DatabaseBackupAgent::getStateText(BackupAgentBase::STATE_ABORTED)));
|
||||
tr->set(StringRef(backupAgent->states.get(logUidValue).pack(DatabaseBackupAgent::keyStateStatus)),
|
||||
StringRef(DatabaseBackupAgent::getStateText(EBackupState::STATE_ABORTED)));
|
||||
|
||||
wait(tr->commit());
|
||||
|
||||
|
@ -2382,13 +2393,11 @@ public:
|
|||
state Future<Optional<Value>> fStopVersionKey = tr->get(backupAgent->states.get(BinaryWriter::toValue(logUid, Unversioned())).pack(BackupAgentBase::keyStateStop));
|
||||
state Future<Optional<Key>> fBackupKeysPacked = tr->get(backupAgent->config.get(BinaryWriter::toValue(logUid, Unversioned())).pack(BackupAgentBase::keyConfigBackupRanges));
|
||||
|
||||
int backupStateInt = wait(backupAgent->getStateValue(tr, logUid));
|
||||
state BackupAgentBase::enumState backupState = (BackupAgentBase::enumState)backupStateInt;
|
||||
|
||||
if (backupState == DatabaseBackupAgent::STATE_NEVERRAN) {
|
||||
state EBackupState backupState = wait(backupAgent->getStateValue(tr, logUid));
|
||||
|
||||
if (backupState == EBackupState::STATE_NEVERRAN) {
|
||||
statusText += "No previous backups found.\n";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state std::string tagNameDisplay;
|
||||
Optional<Key> tagName = wait(fTagName);
|
||||
|
||||
|
@ -2408,23 +2417,20 @@ public:
|
|||
}
|
||||
|
||||
switch (backupState) {
|
||||
case BackupAgentBase::STATE_SUBMITTED:
|
||||
case EBackupState::STATE_SUBMITTED:
|
||||
statusText += "The DR on tag `" + tagNameDisplay + "' is NOT a complete copy of the primary database (just started).\n";
|
||||
break;
|
||||
case BackupAgentBase::STATE_RUNNING:
|
||||
case EBackupState::STATE_RUNNING:
|
||||
statusText += "The DR on tag `" + tagNameDisplay + "' is NOT a complete copy of the primary database.\n";
|
||||
break;
|
||||
case BackupAgentBase::STATE_RUNNING_DIFFERENTIAL:
|
||||
case EBackupState::STATE_RUNNING_DIFFERENTIAL:
|
||||
statusText += "The DR on tag `" + tagNameDisplay + "' is a complete copy of the primary database.\n";
|
||||
break;
|
||||
case BackupAgentBase::STATE_COMPLETED:
|
||||
{
|
||||
case EBackupState::STATE_COMPLETED: {
|
||||
Version stopVersion = stopVersionKey.present() ? BinaryReader::fromStringRef<Version>(stopVersionKey.get(), Unversioned()) : -1;
|
||||
statusText += "The previous DR on tag `" + tagNameDisplay + "' completed at version " + format("%lld", stopVersion) + ".\n";
|
||||
}
|
||||
break;
|
||||
case BackupAgentBase::STATE_PARTIALLY_ABORTED:
|
||||
{
|
||||
} break;
|
||||
case EBackupState::STATE_PARTIALLY_ABORTED: {
|
||||
statusText += "The previous DR on tag `" + tagNameDisplay + "' " + BackupAgentBase::getStateText(backupState) + ".\n";
|
||||
statusText += "Abort the DR with --cleanup before starting a new DR.\n";
|
||||
break;
|
||||
|
@ -2485,13 +2491,15 @@ public:
|
|||
return statusText;
|
||||
}
|
||||
|
||||
ACTOR static Future<int> getStateValue(DatabaseBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, UID logUid, bool snapshot) {
|
||||
ACTOR static Future<EBackupState> getStateValue(DatabaseBackupAgent* backupAgent,
|
||||
Reference<ReadYourWritesTransaction> tr, UID logUid,
|
||||
bool snapshot) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
state Key statusKey = backupAgent->states.get(BinaryWriter::toValue(logUid, Unversioned())).pack(DatabaseBackupAgent::keyStateStatus);
|
||||
Optional<Value> status = wait(tr->get(statusKey, snapshot));
|
||||
|
||||
return (!status.present()) ? DatabaseBackupAgent::STATE_NEVERRAN : BackupAgentBase::getState(status.get().toString());
|
||||
return (!status.present()) ? EBackupState::STATE_NEVERRAN : BackupAgentBase::getState(status.get().toString());
|
||||
}
|
||||
|
||||
ACTOR static Future<UID> getDestUid(DatabaseBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, UID logUid, bool snapshot) {
|
||||
|
@ -2536,7 +2544,8 @@ Future<std::string> DatabaseBackupAgent::getStatus(Database cx, int errorLimit,
|
|||
return DatabaseBackupAgentImpl::getStatus(this, cx, errorLimit, tagName);
|
||||
}
|
||||
|
||||
Future<int> DatabaseBackupAgent::getStateValue(Reference<ReadYourWritesTransaction> tr, UID logUid, bool snapshot) {
|
||||
Future<EBackupState> DatabaseBackupAgent::getStateValue(Reference<ReadYourWritesTransaction> tr, UID logUid,
|
||||
bool snapshot) {
|
||||
return DatabaseBackupAgentImpl::getStateValue(this, tr, logUid, snapshot);
|
||||
}
|
||||
|
||||
|
@ -2552,11 +2561,11 @@ Future<Void> DatabaseBackupAgent::waitUpgradeToLatestDrVersion(Database cx, Key
|
|||
return DatabaseBackupAgentImpl::waitUpgradeToLatestDrVersion(this, cx, tagName);
|
||||
}
|
||||
|
||||
Future<int> DatabaseBackupAgent::waitBackup(Database cx, Key tagName, bool stopWhenDone) {
|
||||
Future<EBackupState> DatabaseBackupAgent::waitBackup(Database cx, Key tagName, bool stopWhenDone) {
|
||||
return DatabaseBackupAgentImpl::waitBackup(this, cx, tagName, stopWhenDone);
|
||||
}
|
||||
|
||||
Future<int> DatabaseBackupAgent::waitSubmitted(Database cx, Key tagName) {
|
||||
Future<EBackupState> DatabaseBackupAgent::waitSubmitted(Database cx, Key tagName) {
|
||||
return DatabaseBackupAgentImpl::waitSubmitted(this, cx, tagName);
|
||||
}
|
||||
|
||||
|
|
|
@ -748,9 +748,10 @@ namespace fileBackup {
|
|||
state Subspace newConfigSpace = uidPrefixKey(LiteralStringRef("uid->config/").withPrefix(fileBackupPrefixRange.begin), uid);
|
||||
|
||||
Optional<Value> statusStr = wait(tr->get(statusSpace.pack(FileBackupAgent::keyStateStatus)));
|
||||
state EBackupState status = !statusStr.present() ? FileBackupAgent::STATE_NEVERRAN : BackupAgentBase::getState(statusStr.get().toString());
|
||||
state EBackupState status =
|
||||
!statusStr.present() ? EBackupState::STATE_NEVERRAN : BackupAgentBase::getState(statusStr.get().toString());
|
||||
|
||||
TraceEvent(SevInfo, "FileBackupAbortIncompatibleBackup")
|
||||
TraceEvent(SevInfo, "FileBackupAbortIncompatibleBackup")
|
||||
.detail("TagName", tagName.c_str())
|
||||
.detail("Status", BackupAgentBase::getStateText(status));
|
||||
|
||||
|
@ -770,9 +771,9 @@ namespace fileBackup {
|
|||
|
||||
// Set old style state key to Aborted if it was Runnable
|
||||
if(backupAgent->isRunnable(status))
|
||||
tr->set(statusKey, StringRef(FileBackupAgent::getStateText(BackupAgentBase::STATE_ABORTED)));
|
||||
tr->set(statusKey, StringRef(FileBackupAgent::getStateText(EBackupState::STATE_ABORTED)));
|
||||
|
||||
return Void();
|
||||
return Void();
|
||||
}
|
||||
|
||||
struct AbortFiveZeroBackupTask : TaskFuncBase {
|
||||
|
@ -822,11 +823,11 @@ namespace fileBackup {
|
|||
state BackupConfig config(current.first);
|
||||
EBackupState status = wait(config.stateEnum().getD(tr, false, EBackupState::STATE_NEVERRAN));
|
||||
|
||||
if (!backupAgent->isRunnable((BackupAgentBase::enumState)status)) {
|
||||
throw backup_unneeded();
|
||||
}
|
||||
if (!backupAgent->isRunnable(status)) {
|
||||
throw backup_unneeded();
|
||||
}
|
||||
|
||||
TraceEvent(SevInfo, "FBA_AbortFileOneBackup")
|
||||
TraceEvent(SevInfo, "FBA_AbortFileOneBackup")
|
||||
.detail("TagName", tagName.c_str())
|
||||
.detail("Status", BackupAgentBase::getStateText(status));
|
||||
|
||||
|
@ -2100,10 +2101,10 @@ namespace fileBackup {
|
|||
}
|
||||
|
||||
// If the backup is restorable but the state is not differential then set state to differential
|
||||
if(restorableVersion.present() && backupState != BackupAgentBase::STATE_RUNNING_DIFFERENTIAL)
|
||||
config.stateEnum().set(tr, BackupAgentBase::STATE_RUNNING_DIFFERENTIAL);
|
||||
if (restorableVersion.present() && backupState != EBackupState::STATE_RUNNING_DIFFERENTIAL)
|
||||
config.stateEnum().set(tr, EBackupState::STATE_RUNNING_DIFFERENTIAL);
|
||||
|
||||
// If stopWhenDone is set and there is a restorable version, set the done future and do not create further tasks.
|
||||
// If stopWhenDone is set and there is a restorable version, set the done future and do not create further tasks.
|
||||
if(stopWhenDone && restorableVersion.present()) {
|
||||
wait(onDone->set(tr, taskBucket) && taskBucket->finish(tr, task));
|
||||
|
||||
|
@ -2350,10 +2351,10 @@ namespace fileBackup {
|
|||
}
|
||||
|
||||
// If the backup is restorable and the state isn't differential the set state to differential
|
||||
if(restorableVersion.present() && backupState != BackupAgentBase::STATE_RUNNING_DIFFERENTIAL)
|
||||
config.stateEnum().set(tr, BackupAgentBase::STATE_RUNNING_DIFFERENTIAL);
|
||||
if (restorableVersion.present() && backupState != EBackupState::STATE_RUNNING_DIFFERENTIAL)
|
||||
config.stateEnum().set(tr, EBackupState::STATE_RUNNING_DIFFERENTIAL);
|
||||
|
||||
// Unless we are to stop, start the next snapshot using the default interval
|
||||
// Unless we are to stop, start the next snapshot using the default interval
|
||||
Reference<TaskFuture> snapshotDoneFuture = task->getDoneFuture(futureBucket);
|
||||
if(!stopWhenDone) {
|
||||
wait(config.initNewSnapshot(tr) && success(BackupSnapshotDispatchTask::addTask(tr, taskBucket, task, 1, TaskCompletionKey::signal(snapshotDoneFuture))));
|
||||
|
@ -3746,7 +3747,9 @@ public:
|
|||
|
||||
// This method will return the final status of the backup at tag, and return the URL that was used on the tag
|
||||
// when that status value was read.
|
||||
ACTOR static Future<int> waitBackup(FileBackupAgent* backupAgent, Database cx, std::string tagName, bool stopWhenDone, Reference<IBackupContainer> *pContainer = nullptr, UID *pUID = nullptr) {
|
||||
ACTOR static Future<EBackupState> waitBackup(FileBackupAgent* backupAgent, Database cx, std::string tagName,
|
||||
bool stopWhenDone, Reference<IBackupContainer>* pContainer = nullptr,
|
||||
UID* pUID = nullptr) {
|
||||
state std::string backTrace;
|
||||
state KeyBackedTag tag = makeBackupTag(tagName);
|
||||
|
||||
|
@ -3767,7 +3770,8 @@ public:
|
|||
// Break, if one of the following is true
|
||||
// - no longer runnable
|
||||
// - in differential mode (restorable) and stopWhenDone is not enabled
|
||||
if( !FileBackupAgent::isRunnable(status) || ((!stopWhenDone) && (BackupAgentBase::STATE_RUNNING_DIFFERENTIAL == status) )) {
|
||||
if (!FileBackupAgent::isRunnable(status) ||
|
||||
((!stopWhenDone) && (EBackupState::STATE_RUNNING_DIFFERENTIAL == status))) {
|
||||
|
||||
if(pContainer != nullptr) {
|
||||
Reference<IBackupContainer> c = wait(config.backupContainer().getOrThrow(tr, false, backup_invalid_info()));
|
||||
|
@ -4103,7 +4107,7 @@ public:
|
|||
state Key destUidValue = wait(config.destUidValue().getOrThrow(tr));
|
||||
EBackupState status = wait(config.stateEnum().getD(tr, false, EBackupState::STATE_NEVERRAN));
|
||||
|
||||
if (!backupAgent->isRunnable((BackupAgentBase::enumState)status)) {
|
||||
if (!backupAgent->isRunnable(status)) {
|
||||
throw backup_unneeded();
|
||||
}
|
||||
|
||||
|
@ -4206,13 +4210,13 @@ public:
|
|||
JsonBuilderObject statusDoc;
|
||||
statusDoc.setKey("Name", BackupAgentBase::getStateName(backupState));
|
||||
statusDoc.setKey("Description", BackupAgentBase::getStateText(backupState));
|
||||
statusDoc.setKey("Completed", backupState == BackupAgentBase::STATE_COMPLETED);
|
||||
statusDoc.setKey("Completed", backupState == EBackupState::STATE_COMPLETED);
|
||||
statusDoc.setKey("Running", BackupAgentBase::isRunnable(backupState));
|
||||
doc.setKey("Status", statusDoc);
|
||||
|
||||
state Future<Void> done = Void();
|
||||
|
||||
if(backupState != BackupAgentBase::STATE_NEVERRAN) {
|
||||
if (backupState != EBackupState::STATE_NEVERRAN) {
|
||||
state Reference<IBackupContainer> bc;
|
||||
state TimestampedVersion latestRestorable;
|
||||
|
||||
|
@ -4224,7 +4228,7 @@ public:
|
|||
|
||||
if(latestRestorable.present()) {
|
||||
JsonBuilderObject o = latestRestorable.toJSON();
|
||||
if(backupState != BackupAgentBase::STATE_COMPLETED) {
|
||||
if (backupState != EBackupState::STATE_COMPLETED) {
|
||||
o.setKey("LagSeconds", (recentReadVersion - latestRestorable.version.get()) / CLIENT_KNOBS->CORE_VERSIONSPERSECOND);
|
||||
}
|
||||
doc.setKey("LatestRestorablePoint", o);
|
||||
|
@ -4232,7 +4236,8 @@ public:
|
|||
doc.setKey("DestinationURL", bc->getURL());
|
||||
}
|
||||
|
||||
if(backupState == BackupAgentBase::STATE_RUNNING_DIFFERENTIAL || backupState == BackupAgentBase::STATE_RUNNING) {
|
||||
if (backupState == EBackupState::STATE_RUNNING_DIFFERENTIAL ||
|
||||
backupState == EBackupState::STATE_RUNNING) {
|
||||
state int64_t snapshotInterval;
|
||||
state int64_t logBytesWritten;
|
||||
state int64_t rangeBytesWritten;
|
||||
|
@ -4355,23 +4360,28 @@ public:
|
|||
bool snapshotProgress = false;
|
||||
|
||||
switch (backupState) {
|
||||
case BackupAgentBase::STATE_SUBMITTED:
|
||||
statusText += "The backup on tag `" + tagName + "' is in progress (just started) to " + bc->getURL() + ".\n";
|
||||
break;
|
||||
case BackupAgentBase::STATE_RUNNING:
|
||||
statusText += "The backup on tag `" + tagName + "' is in progress to " + bc->getURL() + ".\n";
|
||||
snapshotProgress = true;
|
||||
break;
|
||||
case BackupAgentBase::STATE_RUNNING_DIFFERENTIAL:
|
||||
statusText += "The backup on tag `" + tagName + "' is restorable but continuing to " + bc->getURL() + ".\n";
|
||||
snapshotProgress = true;
|
||||
break;
|
||||
case BackupAgentBase::STATE_COMPLETED:
|
||||
statusText += "The previous backup on tag `" + tagName + "' at " + bc->getURL() + " completed at version " + format("%lld", latestRestorableVersion.orDefault(-1)) + ".\n";
|
||||
break;
|
||||
default:
|
||||
statusText += "The previous backup on tag `" + tagName + "' at " + bc->getURL() + " " + backupStatus + ".\n";
|
||||
break;
|
||||
case EBackupState::STATE_SUBMITTED:
|
||||
statusText += "The backup on tag `" + tagName + "' is in progress (just started) to " +
|
||||
bc->getURL() + ".\n";
|
||||
break;
|
||||
case EBackupState::STATE_RUNNING:
|
||||
statusText += "The backup on tag `" + tagName + "' is in progress to " + bc->getURL() + ".\n";
|
||||
snapshotProgress = true;
|
||||
break;
|
||||
case EBackupState::STATE_RUNNING_DIFFERENTIAL:
|
||||
statusText += "The backup on tag `" + tagName + "' is restorable but continuing to " +
|
||||
bc->getURL() + ".\n";
|
||||
snapshotProgress = true;
|
||||
break;
|
||||
case EBackupState::STATE_COMPLETED:
|
||||
statusText += "The previous backup on tag `" + tagName + "' at " + bc->getURL() +
|
||||
" completed at version " + format("%lld", latestRestorableVersion.orDefault(-1)) +
|
||||
".\n";
|
||||
break;
|
||||
default:
|
||||
statusText += "The previous backup on tag `" + tagName + "' at " + bc->getURL() + " " +
|
||||
backupStatus + ".\n";
|
||||
break;
|
||||
}
|
||||
statusText += format("BackupUID: %s\n", uidAndAbortedFlag.get().first.toString().c_str());
|
||||
statusText += format("BackupURL: %s\n", bc->getURL().c_str());
|
||||
|
@ -4407,7 +4417,7 @@ public:
|
|||
);
|
||||
|
||||
statusText += format("Snapshot interval is %lld seconds. ", snapshotInterval);
|
||||
if(backupState == BackupAgentBase::STATE_RUNNING_DIFFERENTIAL)
|
||||
if (backupState == EBackupState::STATE_RUNNING_DIFFERENTIAL)
|
||||
statusText += format("Current snapshot progress target is %3.2f%% (>100%% means the snapshot is supposed to be done)\n", 100.0 * (recentReadVersion - snapshotBeginVersion) / (snapshotTargetEndVersion - snapshotBeginVersion)) ;
|
||||
else
|
||||
statusText += "The initial snapshot is still running.\n";
|
||||
|
@ -4565,7 +4575,7 @@ public:
|
|||
backupConfig = BackupConfig(uidFlag.first);
|
||||
state EBackupState status = wait(backupConfig.stateEnum().getOrThrow(ryw_tr));
|
||||
|
||||
if (status != BackupAgentBase::STATE_RUNNING_DIFFERENTIAL ) {
|
||||
if (status != EBackupState::STATE_RUNNING_DIFFERENTIAL) {
|
||||
throw backup_duplicate();
|
||||
}
|
||||
|
||||
|
@ -4766,7 +4776,8 @@ void FileBackupAgent::setLastRestorable(Reference<ReadYourWritesTransaction> tr,
|
|||
tr->set(lastRestorable.pack(tagName), BinaryWriter::toValue<Version>(version, Unversioned()));
|
||||
}
|
||||
|
||||
Future<int> FileBackupAgent::waitBackup(Database cx, std::string tagName, bool stopWhenDone, Reference<IBackupContainer> *pContainer, UID *pUID) {
|
||||
Future<EBackupState> FileBackupAgent::waitBackup(Database cx, std::string tagName, bool stopWhenDone,
|
||||
Reference<IBackupContainer>* pContainer, UID* pUID) {
|
||||
return FileBackupAgentImpl::waitBackup(this, cx, tagName, stopWhenDone, pContainer, pUID);
|
||||
}
|
||||
|
||||
|
|
|
@ -237,9 +237,12 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
|
|||
// Wait until the backup is in a restorable state and get the status, URL, and UID atomically
|
||||
state Reference<IBackupContainer> lastBackupContainer;
|
||||
state UID lastBackupUID;
|
||||
state int resultWait = wait(backupAgent->waitBackup(cx, backupTag.tagName, false, &lastBackupContainer, &lastBackupUID));
|
||||
state EBackupState resultWait = wait(
|
||||
backupAgent->waitBackup(cx, backupTag.tagName, false, &lastBackupContainer, &lastBackupUID));
|
||||
|
||||
TraceEvent("BARW_DoBackupWaitForRestorable", randomID).detail("Tag", backupTag.tagName).detail("Result", resultWait);
|
||||
TraceEvent("BARW_DoBackupWaitForRestorable", randomID)
|
||||
.detail("Tag", backupTag.tagName)
|
||||
.detail("Result", BackupAgentBase::getStateText(resultWait));
|
||||
|
||||
state bool restorable = false;
|
||||
if (lastBackupContainer) {
|
||||
|
@ -255,23 +258,28 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
|
|||
}
|
||||
|
||||
TraceEvent("BARW_LastBackupContainer", randomID)
|
||||
.detail("BackupTag", printable(tag))
|
||||
.detail("LastBackupContainer", lastBackupContainer ? lastBackupContainer->getURL() : "")
|
||||
.detail("LastBackupUID", lastBackupUID).detail("WaitStatus", resultWait).detail("Restorable", restorable);
|
||||
.detail("BackupTag", printable(tag))
|
||||
.detail("LastBackupContainer", lastBackupContainer ? lastBackupContainer->getURL() : "")
|
||||
.detail("LastBackupUID", lastBackupUID)
|
||||
.detail("WaitStatus", BackupAgentBase::getStateText(resultWait))
|
||||
.detail("Restorable", restorable);
|
||||
|
||||
// Do not check the backup, if aborted
|
||||
if (resultWait == BackupAgentBase::STATE_ABORTED) {
|
||||
if (resultWait == EBackupState::STATE_ABORTED) {
|
||||
}
|
||||
// Ensure that a backup container was found
|
||||
else if (!lastBackupContainer) {
|
||||
TraceEvent(SevError, "BARW_MissingBackupContainer", randomID).detail("LastBackupUID", lastBackupUID).detail("BackupTag", printable(tag)).detail("WaitStatus", resultWait);
|
||||
printf("BackupCorrectnessMissingBackupContainer tag: %s status: %d\n",
|
||||
printable(tag).c_str(), resultWait);
|
||||
printf("BackupCorrectnessMissingBackupContainer tag: %s status: %s\n",
|
||||
printable(tag).c_str(), BackupAgentBase::getStateText(resultWait));
|
||||
}
|
||||
// Check that backup is restorable
|
||||
else if(!restorable) {
|
||||
TraceEvent(SevError, "BARW_NotRestorable", randomID).detail("LastBackupUID", lastBackupUID).detail("BackupTag", printable(tag))
|
||||
.detail("BackupFolder", lastBackupContainer->getURL()).detail("WaitStatus", resultWait);
|
||||
else if (!restorable) {
|
||||
TraceEvent(SevError, "BARW_NotRestorable", randomID)
|
||||
.detail("LastBackupUID", lastBackupUID)
|
||||
.detail("BackupTag", printable(tag))
|
||||
.detail("BackupFolder", lastBackupContainer->getURL())
|
||||
.detail("WaitStatus", BackupAgentBase::getStateText(resultWait));
|
||||
printf("BackupCorrectnessNotRestorable: tag: %s\n", printable(tag).c_str());
|
||||
}
|
||||
|
||||
|
@ -280,7 +288,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
|
|||
if (startDelay) {
|
||||
TraceEvent("BARW_DoBackupAbortBackup2", randomID)
|
||||
.detail("Tag", printable(tag))
|
||||
.detail("WaitStatus", resultWait)
|
||||
.detail("WaitStatus", BackupAgentBase::getStateText(resultWait))
|
||||
.detail("LastBackupContainer", lastBackupContainer ? lastBackupContainer->getURL() : "")
|
||||
.detail("Restorable", restorable);
|
||||
wait(backupAgent->abortBackup(cx, tag.toString()));
|
||||
|
@ -306,7 +314,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
|
|||
|
||||
// Wait for the backup to complete
|
||||
TraceEvent("BARW_DoBackupWaitBackup", randomID).detail("Tag", printable(tag));
|
||||
state int statusValue = wait(backupAgent->waitBackup(cx, tag.toString(), true));
|
||||
state EBackupState statusValue = wait(backupAgent->waitBackup(cx, tag.toString(), true));
|
||||
|
||||
state std::string statusText;
|
||||
|
||||
|
@ -317,7 +325,7 @@ struct BackupAndParallelRestoreCorrectnessWorkload : TestWorkload {
|
|||
TraceEvent("BARW_DoBackupComplete", randomID)
|
||||
.detail("Tag", printable(tag))
|
||||
.detail("Status", statusText)
|
||||
.detail("StatusValue", statusValue);
|
||||
.detail("StatusValue", BackupAgentBase::getStateText(statusValue));
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
|
|
@ -250,9 +250,12 @@ struct BackupAndRestoreCorrectnessWorkload : TestWorkload {
|
|||
// Wait until the backup is in a restorable state and get the status, URL, and UID atomically
|
||||
state Reference<IBackupContainer> lastBackupContainer;
|
||||
state UID lastBackupUID;
|
||||
state int resultWait = wait(backupAgent->waitBackup(cx, backupTag.tagName, false, &lastBackupContainer, &lastBackupUID));
|
||||
state EBackupState resultWait = wait(
|
||||
backupAgent->waitBackup(cx, backupTag.tagName, false, &lastBackupContainer, &lastBackupUID));
|
||||
|
||||
TraceEvent("BARW_DoBackupWaitForRestorable", randomID).detail("Tag", backupTag.tagName).detail("Result", resultWait);
|
||||
TraceEvent("BARW_DoBackupWaitForRestorable", randomID)
|
||||
.detail("Tag", backupTag.tagName)
|
||||
.detail("Result", BackupAgentBase::getStateText(resultWait));
|
||||
|
||||
state bool restorable = false;
|
||||
if(lastBackupContainer) {
|
||||
|
@ -268,31 +271,41 @@ struct BackupAndRestoreCorrectnessWorkload : TestWorkload {
|
|||
}
|
||||
|
||||
TraceEvent("BARW_LastBackupContainer", randomID)
|
||||
.detail("BackupTag", printable(tag))
|
||||
.detail("LastBackupContainer", lastBackupContainer ? lastBackupContainer->getURL() : "")
|
||||
.detail("LastBackupUID", lastBackupUID).detail("WaitStatus", resultWait).detail("Restorable", restorable);
|
||||
.detail("BackupTag", printable(tag))
|
||||
.detail("LastBackupContainer", lastBackupContainer ? lastBackupContainer->getURL() : "")
|
||||
.detail("LastBackupUID", lastBackupUID)
|
||||
.detail("WaitStatus", BackupAgentBase::getStateText(resultWait))
|
||||
.detail("Restorable", restorable);
|
||||
|
||||
// Do not check the backup, if aborted
|
||||
if (resultWait == BackupAgentBase::STATE_ABORTED) {
|
||||
if (resultWait == EBackupState::STATE_ABORTED) {
|
||||
}
|
||||
// Ensure that a backup container was found
|
||||
else if (!lastBackupContainer) {
|
||||
TraceEvent(SevError, "BARW_MissingBackupContainer", randomID).detail("LastBackupUID", lastBackupUID).detail("BackupTag", printable(tag)).detail("WaitStatus", resultWait);
|
||||
printf("BackupCorrectnessMissingBackupContainer tag: %s status: %d\n", printable(tag).c_str(), resultWait);
|
||||
TraceEvent(SevError, "BARW_MissingBackupContainer", randomID)
|
||||
.detail("LastBackupUID", lastBackupUID)
|
||||
.detail("BackupTag", printable(tag))
|
||||
.detail("WaitStatus", BackupAgentBase::getStateText(resultWait));
|
||||
printf("BackupCorrectnessMissingBackupContainer tag: %s status: %s\n",
|
||||
printable(tag).c_str(), BackupAgentBase::getStateText(resultWait));
|
||||
}
|
||||
// Check that backup is restorable
|
||||
else if(!restorable) {
|
||||
TraceEvent(SevError, "BARW_NotRestorable", randomID).detail("LastBackupUID", lastBackupUID).detail("BackupTag", printable(tag))
|
||||
.detail("BackupFolder", lastBackupContainer->getURL()).detail("WaitStatus", resultWait);
|
||||
else if (!restorable) {
|
||||
TraceEvent(SevError, "BARW_NotRestorable", randomID)
|
||||
.detail("LastBackupUID", lastBackupUID)
|
||||
.detail("BackupTag", printable(tag))
|
||||
.detail("BackupFolder", lastBackupContainer->getURL())
|
||||
.detail("WaitStatus", BackupAgentBase::getStateText(resultWait));
|
||||
printf("BackupCorrectnessNotRestorable: tag: %s\n", printable(tag).c_str());
|
||||
}
|
||||
|
||||
// Abort the backup, if not the first backup because the second backup may have aborted the backup by now
|
||||
if (startDelay) {
|
||||
TraceEvent("BARW_DoBackupAbortBackup2", randomID).detail("Tag", printable(tag))
|
||||
.detail("WaitStatus", resultWait)
|
||||
.detail("LastBackupContainer", lastBackupContainer ? lastBackupContainer->getURL() : "")
|
||||
.detail("Restorable", restorable);
|
||||
TraceEvent("BARW_DoBackupAbortBackup2", randomID)
|
||||
.detail("Tag", printable(tag))
|
||||
.detail("WaitStatus", BackupAgentBase::getStateText(resultWait))
|
||||
.detail("LastBackupContainer", lastBackupContainer ? lastBackupContainer->getURL() : "")
|
||||
.detail("Restorable", restorable);
|
||||
wait(backupAgent->abortBackup(cx, tag.toString()));
|
||||
}
|
||||
else {
|
||||
|
@ -315,7 +328,7 @@ struct BackupAndRestoreCorrectnessWorkload : TestWorkload {
|
|||
|
||||
// Wait for the backup to complete
|
||||
TraceEvent("BARW_DoBackupWaitBackup", randomID).detail("Tag", printable(tag));
|
||||
state int statusValue = wait(backupAgent->waitBackup(cx, tag.toString(), true));
|
||||
state EBackupState statusValue = wait(backupAgent->waitBackup(cx, tag.toString(), true));
|
||||
|
||||
state std::string statusText;
|
||||
|
||||
|
@ -323,8 +336,10 @@ struct BackupAndRestoreCorrectnessWorkload : TestWorkload {
|
|||
statusText = _statusText;
|
||||
// Can we validate anything about status?
|
||||
|
||||
TraceEvent("BARW_DoBackupComplete", randomID).detail("Tag", printable(tag))
|
||||
.detail("Status", statusText).detail("StatusValue", statusValue);
|
||||
TraceEvent("BARW_DoBackupComplete", randomID)
|
||||
.detail("Tag", printable(tag))
|
||||
.detail("Status", statusText)
|
||||
.detail("StatusValue", BackupAgentBase::getStateText(statusValue));
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ struct BackupToDBCorrectnessWorkload : TestWorkload {
|
|||
if (BUGGIFY) {
|
||||
TraceEvent("BARW_DoBackupWaitForRestorable", randomID).detail("Tag", printable(tag));
|
||||
// Wait until the backup is in a restorable state
|
||||
state int resultWait = wait(backupAgent->waitBackup(cx, tag, false));
|
||||
state EBackupState resultWait = wait(backupAgent->waitBackup(cx, tag, false));
|
||||
|
||||
TraceEvent("BARW_LastBackupFolder", randomID).detail("BackupTag", printable(tag))
|
||||
.detail("LogUid", logUid).detail("WaitStatus", resultWait);
|
||||
|
@ -309,7 +309,7 @@ struct BackupToDBCorrectnessWorkload : TestWorkload {
|
|||
UID _destUid = wait(backupAgent->getDestUid(cx, logUid));
|
||||
self->destUid = _destUid;
|
||||
|
||||
state int statusValue = wait(backupAgent->waitBackup(cx, tag, true));
|
||||
state EBackupState statusValue = wait(backupAgent->waitBackup(cx, tag, true));
|
||||
wait(backupAgent->unlockBackup(cx, tag));
|
||||
|
||||
state std::string statusText;
|
||||
|
|
Loading…
Reference in New Issue