Add a backup start key

If the backup key is not set, do not recruit backup workers for old epoches.
This commit is contained in:
Jingyu Zhou 2020-01-04 14:33:50 -08:00
parent e14246ac16
commit c08a192c75
4 changed files with 17 additions and 0 deletions

View File

@ -494,6 +494,7 @@ ProcessData decodeWorkerListValue( ValueRef const& value ) {
const KeyRangeRef backupProgressKeys(LiteralStringRef("\xff/backupProgress/"),
LiteralStringRef("\xff/backupProgress0"));
const KeyRef backupProgressPrefix = backupProgressKeys.begin;
const KeyRef backupStartedKey = LiteralStringRef("\xff/backupStarted");
const Key backupProgressKeyFor(UID workerID) {
BinaryWriter wr(Unversioned());

View File

@ -182,6 +182,9 @@ const Value backupProgressValue(const WorkerBackupStatus& status);
UID decodeBackupProgressKey(const KeyRef& key);
WorkerBackupStatus decodeBackupProgressValue(const ValueRef& value);
// "\xff/backupStarted"
extern const KeyRef backupStartedKey;
extern const KeyRef coordinatorsKey;
extern const KeyRef logsKey;
extern const KeyRef minRequiredCommitVersionKey;

View File

@ -20,6 +20,8 @@ void BackupProgress::addBackupStatus(const WorkerBackupStatus& status) {
std::map<std::pair<LogEpoch, Version>, std::map<Tag, Version>> BackupProgress::getUnfinishedBackup() {
std::map<std::pair<LogEpoch, Version>, std::map<Tag, Version>> toRecruit;
if (!backupStartedValue.present()) return toRecruit; // No active backups
for (const auto& [epoch, info] : epochInfos) {
std::set<Tag> tags = enumerateLogRouterTags(info.logRouterTags);
std::map<Tag, Version> tagVersions;
@ -60,9 +62,11 @@ ACTOR Future<Void> getBackupProgress(Database cx, UID dbgid, Reference<BackupPro
try {
tr.setOption(FDBTransactionOptions::ACCESS_SYSTEM_KEYS);
tr.setOption(FDBTransactionOptions::PRIORITY_SYSTEM_IMMEDIATE);
state Optional<Value> value = wait(tr.get(backupStartedKey));
Standalone<RangeResultRef> results = wait(tr.getRange(backupProgressKeys, CLIENT_KNOBS->TOO_MANY));
ASSERT(!results.more && results.size() < CLIENT_KNOBS->TOO_MANY);
bStatus->setBackupStartedValue(value);
for (auto& it : results) {
const UID workerID = decodeBackupProgressKey(it.key);
const WorkerBackupStatus status = decodeBackupProgressValue(it.value);
@ -87,6 +91,7 @@ TEST_CASE("/BackupProgress/Unfinished") {
const Tag tag1(tagLocalityLogRouter, 0);
epochInfos.insert({ epoch1, ILogSystem::EpochTagsVersionsInfo(1, begin1, end1) });
BackupProgress progress(UID(0, 0), epochInfos);
progress.setBackupStartedValue(Optional<Value>(LiteralStringRef("1")));
std::map<std::pair<LogEpoch, Version>, std::map<Tag, Version>> unfinished = progress.getUnfinishedBackup();

View File

@ -51,6 +51,11 @@ public:
// backup [savedVersion + 1, endVersion)
std::map<std::pair<LogEpoch, Version>, std::map<Tag, Version>> getUnfinishedBackup();
// Set the value for "backupStartedKey"
void setBackupStartedValue(Optional<Value> value) {
backupStartedValue = value;
}
void addref() { ReferenceCounted<BackupProgress>::addref(); }
void delref() { ReferenceCounted<BackupProgress>::delref(); }
@ -73,6 +78,9 @@ private:
// progress status for a tag in an epoch due to later epoch trying to fill
// the gap. "progress" MUST be iterated in ascending order.
std::map<LogEpoch, std::map<Tag, Version>> progress;
// Value of the "backupStartedKey".
Optional<Value> backupStartedValue;
};
ACTOR Future<Void> getBackupProgress(Database cx, UID dbgid, Reference<BackupProgress> bStatus);