Clean up empty physical shards in KVS. (#7674)

This commit is contained in:
Yao Xiao 2022-08-04 02:12:04 -07:00 committed by GitHub
parent 4f75f01882
commit 5ee40bbc5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -8607,10 +8607,19 @@ ACTOR Future<Void> updateStorage(StorageServer* data) {
.detail("OldestRemoveKVSRangesVersion", data->pendingRemoveRanges.begin()->first);
ASSERT(newOldestVersion <= data->pendingRemoveRanges.begin()->first);
if (newOldestVersion == data->pendingRemoveRanges.begin()->first) {
state std::vector<std::string> emptyShardIds;
for (const auto& range : data->pendingRemoveRanges.begin()->second) {
data->storage.removeRange(range);
auto ids = data->storage.removeRange(range);
emptyShardIds.insert(emptyShardIds.end(), ids.begin(), ids.end());
TraceEvent(SevVerbose, "RemoveKVSRange", data->thisServerID).detail("Range", range);
}
if (emptyShardIds.size() > 0) {
state double start = now();
wait(data->storage.cleanUpShardsIfNeeded(emptyShardIds));
TraceEvent(SevInfo, "RemoveEmptyPhysicalShards", data->thisServerID)
.detail("NumShards", emptyShardIds.size())
.detail("TimeSpent", now() - start);
}
data->pendingRemoveRanges.erase(data->pendingRemoveRanges.begin());
}
removeKVSRanges = false;