Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

CreateBackup: backup IncrementalId as well #526

Merged
merged 3 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/meta/MetaServiceUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ static const std::unordered_map<std::string, std::pair<std::string, bool>> syste
{"groups", {"__groups__", true}},
{"zones", {"__zones__", true}},
{"ft_service", {"__ft_service__", false}},
{"sessions", {"__sessions__", true}}};
{"sessions", {"__sessions__", true}},
{"id", {"__id__", true}}
};

// name => {prefix, parseSpaceid}, nullptr means that the backup should be skipped.
static const std::unordered_map<
Expand Down Expand Up @@ -80,6 +82,8 @@ const std::string kFTIndexTable = tableMaps.at("ft_index").first;
const std::string kFTServiceTable = systemTableMaps.at("ft_service").first; // NOLINT
const std::string kSessionsTable = systemTableMaps.at("sessions").first; // NOLINT

const std::string kIdKey = systemTableMaps.at("id").first; // NOLINT

const int kMaxIpAddrLen = 15; // '255.255.255.255'

namespace {
Expand Down Expand Up @@ -1007,6 +1011,10 @@ std::string MetaServiceUtils::genTimestampStr() {
return ch;
}

std::string MetaServiceUtils::idKey() {
return kIdKey;
}

std::function<bool(const folly::StringPiece& key)>
MetaServiceUtils::spaceFilter(const std::unordered_set<GraphSpaceID>& spaces,
std::function<GraphSpaceID(folly::StringPiece rawKey)> parseSpace) {
Expand Down
2 changes: 2 additions & 0 deletions src/meta/MetaServiceUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ class MetaServiceUtils final {
static GraphSpaceID parseIndexKeySpaceID(folly::StringPiece key);
static GraphSpaceID parseDefaultKeySpaceID(folly::StringPiece key);

static std::string idKey();

// backup
static ErrorOr<nebula::cpp2::ErrorCode, std::vector<std::string>> backupIndex(
kvstore::KVStore* kvstore,
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/BaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ ErrorOr<nebula::cpp2::ErrorCode, std::vector<HostAddr>> BaseProcessor<RESP>::all
template<typename RESP>
ErrorOr<nebula::cpp2::ErrorCode, int32_t> BaseProcessor<RESP>::autoIncrementId() {
folly::SharedMutex::WriteHolder holder(LockUtils::idLock());
static const std::string kIdKey = "__id__";
const std::string kIdKey = MetaServiceUtils::idKey();
int32_t id;
std::string val;
auto ret = kvstore_->get(kDefaultSpaceId, kDefaultPartId, kIdKey, &val);
Expand Down