2019-10-01 04:16:28 +08:00
|
|
|
/*
|
|
|
|
* BackupProgress.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2019 Apple Inc. and the FoundationDB project authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(NO_INTELLISENSE) && !defined(FDBSERVER_BACKUPPROGRESS_ACTOR_G_H)
|
|
|
|
#define FDBSERVER_BACKUPPROGRESS_ACTOR_G_H
|
|
|
|
#include "fdbserver/BackupProgress.actor.g.h"
|
|
|
|
#elif !defined(FDBSERVER_BACKUPPROGRESS_ACTOR_H)
|
|
|
|
#define FDBSERVER_BACKUPPROGRESS_ACTOR_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include "fdbclient/FDBTypes.h"
|
2019-10-02 05:55:08 +08:00
|
|
|
#include "fdbserver/LogSystem.h"
|
2019-10-01 04:16:28 +08:00
|
|
|
#include "flow/Arena.h"
|
|
|
|
#include "flow/FastRef.h"
|
|
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
|
|
|
|
2019-10-02 04:24:28 +08:00
|
|
|
class BackupProgress : NonCopyable, ReferenceCounted<BackupProgress> {
|
2019-10-01 04:16:28 +08:00
|
|
|
public:
|
2019-10-02 05:55:08 +08:00
|
|
|
BackupProgress(UID id, const std::map<LogEpoch, ILogSystem::EpochTagsVersionsInfo>& infos)
|
|
|
|
: dbgid(id), epochInfos(infos) {}
|
2019-10-01 04:16:28 +08:00
|
|
|
~BackupProgress() {}
|
|
|
|
|
|
|
|
// Adds a backup status. If the tag already has an entry, then the max of
|
|
|
|
// savedVersion is used.
|
|
|
|
void addBackupStatus(const WorkerBackupStatus& status);
|
|
|
|
|
|
|
|
// Returns a map of pair<Epoch, endVersion> : map<tag, savedVersion>, so that
|
|
|
|
// the backup range should be [savedVersion + 1, endVersion) for the "tag" of the "Epoch".
|
|
|
|
//
|
2019-10-02 05:55:08 +08:00
|
|
|
// Specifically, the backup ranges for each old epoch are:
|
2019-10-01 04:16:28 +08:00
|
|
|
// if tag in tags_without_backup_progress:
|
2019-10-02 05:55:08 +08:00
|
|
|
// backup [epochBegin, endVersion)
|
2019-10-01 04:16:28 +08:00
|
|
|
// else if savedVersion < endVersion - 1 = knownCommittedVersion
|
2019-10-02 05:55:08 +08:00
|
|
|
// backup [savedVersion + 1, endVersion)
|
2019-10-01 04:16:28 +08:00
|
|
|
std::map<std::pair<LogEpoch, Version>, std::map<Tag, Version>> getUnfinishedBackup();
|
|
|
|
|
2020-01-05 06:33:50 +08:00
|
|
|
// Set the value for "backupStartedKey"
|
|
|
|
void setBackupStartedValue(Optional<Value> value) {
|
|
|
|
backupStartedValue = value;
|
|
|
|
}
|
|
|
|
|
2019-10-02 06:57:41 +08:00
|
|
|
void addref() { ReferenceCounted<BackupProgress>::addref(); }
|
2019-10-02 04:24:28 +08:00
|
|
|
|
2019-10-02 06:57:41 +08:00
|
|
|
void delref() { ReferenceCounted<BackupProgress>::delref(); }
|
2019-10-02 04:24:28 +08:00
|
|
|
|
2019-10-01 04:16:28 +08:00
|
|
|
private:
|
|
|
|
std::set<Tag> enumerateLogRouterTags(int logRouterTags) {
|
|
|
|
std::set<Tag> tags;
|
|
|
|
for (int i = 0; i < logRouterTags; i++) {
|
|
|
|
tags.insert(Tag(tagLocalityLogRouter, i));
|
|
|
|
}
|
|
|
|
return tags;
|
|
|
|
}
|
|
|
|
|
|
|
|
const UID dbgid;
|
|
|
|
|
2019-10-02 05:55:08 +08:00
|
|
|
// Note this MUST be iterated in ascending order.
|
|
|
|
const std::map<LogEpoch, ILogSystem::EpochTagsVersionsInfo> epochInfos;
|
2019-10-01 04:16:28 +08:00
|
|
|
|
|
|
|
// Backup progress saved in the system keyspace. Note there can be multiple
|
|
|
|
// progress status for a tag in an epoch due to later epoch trying to fill
|
2019-10-02 05:55:08 +08:00
|
|
|
// the gap. "progress" MUST be iterated in ascending order.
|
2019-10-01 04:16:28 +08:00
|
|
|
std::map<LogEpoch, std::map<Tag, Version>> progress;
|
2020-01-05 06:33:50 +08:00
|
|
|
|
|
|
|
// Value of the "backupStartedKey".
|
|
|
|
Optional<Value> backupStartedValue;
|
2019-10-01 04:16:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ACTOR Future<Void> getBackupProgress(Database cx, UID dbgid, Reference<BackupProgress> bStatus);
|
|
|
|
|
|
|
|
#include "flow/unactorcompiler.h"
|
|
|
|
#endif
|