Cherry-picked from #45047 Co-authored-by: Kaijie Chen <chenkaijie@selectdb.com>
This commit is contained in:
committed by
GitHub
parent
53291bd040
commit
08c8a416ea
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user