This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 08c8a416ea2 branch-2.1: [fix](runtime_profile) fix race condition in
to_thrift #45047 (#45099)
08c8a416ea2 is described below
commit 08c8a416ea2fb7e2ef3abe76454c4a8dc5ae995a
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Dec 6 16:25:33 2024 +0800
branch-2.1: [fix](runtime_profile) fix race condition in to_thrift #45047
(#45099)
Cherry-picked from #45047
Co-authored-by: Kaijie Chen <[email protected]>
---
be/src/util/runtime_profile.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/be/src/util/runtime_profile.cpp b/be/src/util/runtime_profile.cpp
index 782009d4438..93f1406f2aa 100644
--- a/be/src/util/runtime_profile.cpp
+++ b/be/src/util/runtime_profile.cpp
@@ -576,8 +576,6 @@ void RuntimeProfile::to_thrift(TRuntimeProfileTree* tree) {
}
void RuntimeProfile::to_thrift(std::vector<TRuntimeProfileNode>* nodes) {
- nodes->reserve(nodes->size() + _children.size());
-
int index = nodes->size();
nodes->push_back(TRuntimeProfileNode());
TRuntimeProfileNode& node = (*nodes)[index];
@@ -607,10 +605,13 @@ void
RuntimeProfile::to_thrift(std::vector<TRuntimeProfileNode>* nodes) {
ChildVector children;
{
+ // _children may be modified during to_thrift(),
+ // so we have to lock and copy _children to avoid race condition
std::lock_guard<std::mutex> l(_children_lock);
children = _children;
}
node.num_children = children.size();
+ nodes->reserve(nodes->size() + children.size());
for (int i = 0; i < children.size(); ++i) {
int child_idx = nodes->size();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]