[optimize](cooldown)Shorten the _meta_lock lock interval (#27118)

Change the two passes of _rs_version_map to one, reducing cpu overhead and shortening the lock interval of _meta_lock

Co-authored-by: xingying01@corp.netease.com <xingying01@corp.netease.com>
This commit is contained in:
xy
2023-11-17 16:59:36 +08:00
committed by GitHub
parent ab322eaa2b
commit fdec286e82

View File

@ -2296,23 +2296,22 @@ Status Tablet::_follow_cooldowned_data() {
return Status::InternalError<false>("tablet not running");
}
for (auto& [v, rs] : _rs_version_map) {
if (v.second == cooldowned_version) {
version_aligned = true;
break;
}
}
if (!version_aligned) {
return Status::InternalError<false>("cooldowned version is not aligned");
}
for (auto& [v, rs] : _rs_version_map) {
if (v.second <= cooldowned_version) {
overlap_rowsets.push_back(rs);
if (!version_aligned && v.second == cooldowned_version) {
version_aligned = true;
}
} else if (!rs->is_local()) {
return Status::InternalError<false>(
"cooldowned version larger than that to follow");
}
}
if (!version_aligned) {
return Status::InternalError<false>("cooldowned version is not aligned");
}
std::sort(overlap_rowsets.begin(), overlap_rowsets.end(), Rowset::comparator);
auto rs_pb_it = cooldown_meta_pb.rs_metas().begin();
auto rs_it = overlap_rowsets.begin();