Skip to content

Commit

Permalink
sync local_id to slave cluster (vesoft-inc#2873)
Browse files Browse the repository at this point in the history
  • Loading branch information
critical27 authored Jun 29, 2023
1 parent 2ec4b11 commit 2850e8d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 4 deletions.
1 change: 0 additions & 1 deletion conf/nebula-standalone.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@

########## Disk ##########
# Root data path. Split by comma. e.g. --data_path=/disk1/path1/,/disk2/path2/
# One path per Rocksdb instance.
--data_path=data/storage

# Minimum reserved bytes of each data path
Expand Down
1 change: 0 additions & 1 deletion conf/nebula-standalone.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@

########## Disk ##########
# Root data path. Split by comma. e.g. --data_path=/disk1/path1/,/disk2/path2/
# One path per Rocksdb instance.
--data_path=data/storage

# Minimum reserved bytes of each data path
Expand Down
1 change: 0 additions & 1 deletion conf/nebula-storaged.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

########## Disk ##########
# Root data path. Split by comma. e.g. --data_path=/disk1/path1/,/disk2/path2/
# One path per Rocksdb instance.
--data_path=data/storage

# Minimum reserved bytes of each data path
Expand Down
1 change: 0 additions & 1 deletion conf/nebula-storaged.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

########## Disk ##########
# Root data path. split by comma. e.g. --data_path=/disk1/path1/,/disk2/path2/
# One path per Rocksdb instance.
--data_path=data/storage

# Minimum reserved bytes of each data path
Expand Down
9 changes: 9 additions & 0 deletions src/common/utils/MetaKeyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,15 @@ std::string MetaKeyUtils::localIdKey(GraphSpaceID spaceId) {
return key;
}

bool MetaKeyUtils::isLocalIdKey(const std::string& key) {
if (key.size() != kLocalIdTable.size() + sizeof(GraphSpaceID)) {
return false;
}

auto prefix = key.substr(0, kLocalIdTable.size());
return prefix == kLocalIdTable;
}

GraphSpaceID MetaKeyUtils::parseLocalIdSpace(folly::StringPiece rawData) {
auto offset = kLocalIdTable.size();
return *reinterpret_cast<const GraphSpaceID*>(rawData.data() + offset);
Expand Down
2 changes: 2 additions & 0 deletions src/common/utils/MetaKeyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ class MetaKeyUtils final {

static std::string localIdKey(GraphSpaceID spaceId);

static bool isLocalIdKey(const std::string& key);

static GraphSpaceID parseLocalIdSpace(folly::StringPiece rawData);

static std::string getIndexTable();
Expand Down
2 changes: 2 additions & 0 deletions src/drainer/DrainerTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,8 @@ StatusOr<std::string> DrainerTask::adjustSpaceIdInKey(GraphSpaceID space,
} else if (MetaKeyUtils::isIndexKey(key)) {
// _indexes_spaceId_indexID
return MetaKeyUtils::replaceIndexKey(space, key);
} else if (MetaKeyUtils::isLocalIdKey(key)) {
return MetaKeyUtils::localIdKey(space);
}

VLOG(2) << "Not tag/edge/index schema data ";
Expand Down
2 changes: 2 additions & 0 deletions src/kvstore/listener/sync/SyncListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,8 @@ StatusOr<GraphSpaceID> MetaSyncListener::getSpaceIdInKey(const folly::StringPiec
} else if (MetaKeyUtils::isIndexKey(key)) {
// _indexes_spaceId_indexID
return MetaKeyUtils::parseIndexesKeySpaceID(key);
} else if (MetaKeyUtils::isLocalIdKey(key)) {
return MetaKeyUtils::parseLocalIdSpace(key);
}
return nebula::Status::Error("Not tag/edge/index schema data");
}
Expand Down

0 comments on commit 2850e8d

Please sign in to comment.