More backup cleanup.
This commit is contained in:
parent
c7df951f7c
commit
02cc8b43c4
|
@ -864,7 +864,6 @@ ACTOR Future<std::string> getLayerStatus(Reference<ReadYourWritesTransaction> tr
|
|||
|
||||
state FileBackupAgent fba;
|
||||
state std::vector<KeyBackedTag> backupTags = wait(getAllBackupTags(tr));
|
||||
state Standalone<RangeResultRef> backupTagNames = wait( tr->getRange(fba.tagNames.range(), 10000));
|
||||
state std::vector<Future<Version>> tagLastRestorableVersions;
|
||||
state std::vector<Future<int>> tagStates;
|
||||
state std::vector<Future<std::string>> tagContainers;
|
||||
|
@ -1222,12 +1221,17 @@ ACTOR Future<Void> submitBackup(Database db, std::string destinationDir, Standal
|
|||
}
|
||||
|
||||
if (dryRun) {
|
||||
state UID logUid = wait(backupAgent.getLogUid(db, StringRef(tagName)));
|
||||
state int backupStatus = wait(backupAgent.getStateValue(db, logUid));
|
||||
state KeyBackedTag tag = makeBackupTag(tagName);
|
||||
Optional<UidAndAbortedFlagT> uidFlag = wait(tag.get(db));
|
||||
|
||||
// Throw error if a backup is currently running until we support parallel backups
|
||||
if (BackupAgentBase::isRunnable((BackupAgentBase::enumState)backupStatus)) {
|
||||
throw backup_duplicate();
|
||||
if (uidFlag.present()) {
|
||||
BackupConfig config(uidFlag.get().first);
|
||||
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)) {
|
||||
throw backup_duplicate();
|
||||
}
|
||||
}
|
||||
|
||||
if (waitForCompletion) {
|
||||
|
|
|
@ -220,7 +220,6 @@ public:
|
|||
subspace( std::move(r.subspace) ),
|
||||
config( std::move(r.config) ),
|
||||
errors( std::move(r.errors) ),
|
||||
tagNames( std::move(r.tagNames) ),
|
||||
lastRestorable( std::move(r.lastRestorable) ),
|
||||
taskBucket( std::move(r.taskBucket) ),
|
||||
futureBucket( std::move(r.futureBucket) ) {}
|
||||
|
@ -229,7 +228,6 @@ public:
|
|||
subspace = std::move(r.subspace);
|
||||
config = std::move(r.config);
|
||||
errors = std::move(r.errors);
|
||||
tagNames = std::move(r.tagNames);
|
||||
lastRestorable = std::move(r.lastRestorable),
|
||||
taskBucket = std::move(r.taskBucket);
|
||||
futureBucket = std::move(r.futureBucket);
|
||||
|
@ -291,21 +289,6 @@ public:
|
|||
|
||||
Future<std::string> getStatus(Database cx, int errorLimit, std::string tagName);
|
||||
|
||||
Future<int> getStateValue(Reference<ReadYourWritesTransaction> tr, UID logUid);
|
||||
Future<int> getStateValue(Database cx, UID logUid) {
|
||||
return runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr){ return getStateValue(tr, logUid); });
|
||||
}
|
||||
|
||||
Future<Version> getStateStopVersion(Reference<ReadYourWritesTransaction> tr, UID logUid);
|
||||
Future<Version> getStateStopVersion(Database cx, UID logUid) {
|
||||
return runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr){ return getStateStopVersion(tr, logUid); });
|
||||
}
|
||||
|
||||
Future<UID> getLogUid(Reference<ReadYourWritesTransaction> tr, Key tagName);
|
||||
Future<UID> getLogUid(Database cx, Key tagName) {
|
||||
return runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr){ return getLogUid(tr, tagName); });
|
||||
}
|
||||
|
||||
Future<Version> getLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName);
|
||||
|
||||
// stopWhenDone will return when the backup is stopped, if enabled. Otherwise, it
|
||||
|
@ -334,7 +317,6 @@ public:
|
|||
Subspace subspace;
|
||||
Subspace config;
|
||||
Subspace errors;
|
||||
Subspace tagNames;
|
||||
Subspace lastRestorable;
|
||||
|
||||
Reference<TaskBucket> taskBucket;
|
||||
|
|
|
@ -315,8 +315,6 @@ ACTOR Future<std::string> RestoreConfig::getFullStatus_impl(RestoreConfig restor
|
|||
|
||||
FileBackupAgent::FileBackupAgent()
|
||||
: subspace(Subspace(fileBackupPrefixRange.begin))
|
||||
// tagNames has tagName => logUID
|
||||
, tagNames(subspace.get(BackupAgentBase::keyTagName))
|
||||
// The other subspaces have logUID -> value
|
||||
, config(subspace.get(BackupAgentBase::keyConfig))
|
||||
, errors(subspace.get(BackupAgentBase::keyErrors))
|
||||
|
@ -3349,7 +3347,6 @@ public:
|
|||
// Point the tag to this new uid
|
||||
tag.set(tr, {uid, false});
|
||||
|
||||
tr->set(backupAgent->tagNames.pack(tagName), config.getUidAsKey());
|
||||
backupAgent->lastBackupTimestamp().set(tr, nowStr);
|
||||
|
||||
// Set the backup keys
|
||||
|
@ -3600,28 +3597,6 @@ public:
|
|||
return statusText;
|
||||
}
|
||||
|
||||
ACTOR static Future<int> getStateValue(FileBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, UID logUid) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
EBackupState state = wait(BackupConfig(logUid).stateEnum().getD(tr, EBackupState::STATE_NEVERRAN));
|
||||
return state;
|
||||
}
|
||||
|
||||
ACTOR static Future<Version> getStateStopVersion(FileBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, UID logUid) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
Version stopVersion = wait(BackupConfig(logUid).stopVersion().getD(tr, -1));
|
||||
return stopVersion;
|
||||
}
|
||||
|
||||
ACTOR static Future<UID> getLogUid(FileBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, Key tagName) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
state Optional<Value> logUid = wait(tr->get(backupAgent->tagNames.pack(tagName)));
|
||||
|
||||
return (logUid.present()) ? BinaryReader::fromStringRef<UID>(logUid.get(), Unversioned()) : UID();
|
||||
}
|
||||
|
||||
ACTOR static Future<Version> getLastRestorable(FileBackupAgent* backupAgent, Reference<ReadYourWritesTransaction> tr, Key tagName) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
|
@ -3842,18 +3817,6 @@ Future<std::string> FileBackupAgent::getStatus(Database cx, int errorLimit, std:
|
|||
return FileBackupAgentImpl::getStatus(this, cx, errorLimit, tagName);
|
||||
}
|
||||
|
||||
Future<int> FileBackupAgent::getStateValue(Reference<ReadYourWritesTransaction> tr, UID logUid) {
|
||||
return FileBackupAgentImpl::getStateValue(this, tr, logUid);
|
||||
}
|
||||
|
||||
Future<Version> FileBackupAgent::getStateStopVersion(Reference<ReadYourWritesTransaction> tr, UID logUid) {
|
||||
return FileBackupAgentImpl::getStateStopVersion(this, tr, logUid);
|
||||
}
|
||||
|
||||
Future<UID> FileBackupAgent::getLogUid(Reference<ReadYourWritesTransaction> tr, Key tagName) {
|
||||
return FileBackupAgentImpl::getLogUid(this, tr, tagName);
|
||||
}
|
||||
|
||||
Future<Version> FileBackupAgent::getLastRestorable(Reference<ReadYourWritesTransaction> tr, Key tagName) {
|
||||
return FileBackupAgentImpl::getLastRestorable(this, tr, tagName);
|
||||
}
|
||||
|
|
|
@ -132,6 +132,15 @@ public:
|
|||
});
|
||||
}
|
||||
|
||||
Future<Optional<T>> get(Database cx, bool snapshot = false) const {
|
||||
return runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
tr->setOption(FDBTransactionOptions::LOCK_AWARE);
|
||||
|
||||
return get(tr, snapshot);
|
||||
});
|
||||
}
|
||||
|
||||
Future<T> getOrThrow(Database cx, bool snapshot = false, Error err = key_not_found()) const {
|
||||
return runRYWTransaction(cx, [=](Reference<ReadYourWritesTransaction> tr) {
|
||||
tr->setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
|
||||
|
|
Loading…
Reference in New Issue