Skip to content

Commit b28f68f

Browse files
[BugFix] Fix RuntimeProfile min/max race during serialization (backport #72904) (#74216)
Signed-off-by: stephen <stephen5217@163.com> Co-authored-by: stephen <91597003+stephen-shelby@users.noreply.github.com>
1 parent 3cc69b7 commit b28f68f

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

be/src/util/runtime_profile.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,18 @@ void RuntimeProfile::to_thrift(std::vector<TRuntimeProfileNode>* nodes) {
817817
counter.__set_value(iter_counter->value());
818818
counter.__set_type(iter_counter->type());
819819
counter.__set_strategy(iter_counter->strategy());
820-
if (iter_counter->_min_value.has_value()) {
821-
counter.__set_min_value(iter_counter->_min_value.value());
820+
std::optional<int64_t> min_value;
821+
std::optional<int64_t> max_value;
822+
{
823+
std::lock_guard<std::mutex> l(_counter_lock);
824+
min_value = iter_counter->_min_value;
825+
max_value = iter_counter->_max_value;
822826
}
823-
if (iter_counter->_max_value.has_value()) {
824-
counter.__set_max_value(iter_counter->_max_value.value());
827+
if (min_value.has_value()) {
828+
counter.__set_min_value(min_value.value());
829+
}
830+
if (max_value.has_value()) {
831+
counter.__set_max_value(max_value.value());
825832
}
826833
node.counters.push_back(counter);
827834
}

0 commit comments

Comments
 (0)