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

Commit

Permalink
CreateBackup: backup IncrementalId as well (#526)
Browse files Browse the repository at this point in the history
* CreateBackup: backup IncrementId as well

* remove static declaration

Co-authored-by: CBS <[email protected]>
  • Loading branch information
linkensphere201 and bright-starry-sky authored Jul 16, 2021
1 parent 79e03de commit 0dfa699
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit 0dfa699

Please sign in to comment.