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 b86e4e84989 [fix](profile) fix possible coredump of rpc verbose
profile (#40117)
b86e4e84989 is described below
commit b86e4e84989ba0f0eabbd7bded22758b6ca925aa
Author: TengJianPing <[email protected]>
AuthorDate: Thu Aug 29 23:54:52 2024 +0800
[fix](profile) fix possible coredump of rpc verbose profile (#40117)
## Proposed changes
Issue Number: close #xxx
`_instance_to_rpc_stats_vec` may be updated when sorting in
`ExchangeSinkBuffer<Parent>::update_profile`, which may cause coredump.
---
be/src/pipeline/exec/exchange_sink_buffer.cpp | 28 ++++++++++++----------
.../java/org/apache/doris/qe/SessionVariable.java | 2 +-
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/be/src/pipeline/exec/exchange_sink_buffer.cpp
b/be/src/pipeline/exec/exchange_sink_buffer.cpp
index c4bb736c6f9..54c29a0222e 100644
--- a/be/src/pipeline/exec/exchange_sink_buffer.cpp
+++ b/be/src/pipeline/exec/exchange_sink_buffer.cpp
@@ -555,25 +555,29 @@ void
ExchangeSinkBuffer<Parent>::update_profile(RuntimeProfile* profile) {
if constexpr (std::is_same_v<ExchangeSinkLocalState, Parent>) {
auto max_count = _state->rpc_verbose_profile_max_instance_count();
if (_state->enable_verbose_profile() && max_count > 0) {
- pdqsort(_instance_to_rpc_stats_vec.begin(),
_instance_to_rpc_stats_vec.end(),
- [](const auto& a, const auto& b) { return a->max_time >
b->max_time; });
- auto count = std::min((size_t)max_count,
_instance_to_rpc_stats_vec.size());
+ std::vector<RpcInstanceStatistics> tmp_rpc_stats_vec;
+ for (const auto& stats : _instance_to_rpc_stats_vec) {
+ tmp_rpc_stats_vec.emplace_back(*stats);
+ }
+ pdqsort(tmp_rpc_stats_vec.begin(), tmp_rpc_stats_vec.end(),
+ [](const auto& a, const auto& b) { return a.max_time >
b.max_time; });
+ auto count = std::min((size_t)max_count, tmp_rpc_stats_vec.size());
int i = 0;
auto* detail_profile = profile->create_child("RpcInstanceDetails",
true, true);
- for (const auto& stats : _instance_to_rpc_stats_vec) {
- if (0 == stats->rpc_count) {
+ for (const auto& stats : tmp_rpc_stats_vec) {
+ if (0 == stats.rpc_count) {
continue;
}
std::stringstream out;
- out << "Instance " << std::hex << stats->inst_lo_id;
+ out << "Instance " << std::hex << stats.inst_lo_id;
auto stats_str = fmt::format(
"Count: {}, MaxTime: {}, MinTime: {}, AvgTime: {},
SumTime: {}",
- stats->rpc_count,
PrettyPrinter::print(stats->max_time, TUnit::TIME_NS),
- PrettyPrinter::print(stats->min_time, TUnit::TIME_NS),
- PrettyPrinter::print(stats->sum_time /
std::max(static_cast<int64_t>(1),
-
stats->rpc_count),
- TUnit::TIME_NS),
- PrettyPrinter::print(stats->sum_time, TUnit::TIME_NS));
+ stats.rpc_count, PrettyPrinter::print(stats.max_time,
TUnit::TIME_NS),
+ PrettyPrinter::print(stats.min_time, TUnit::TIME_NS),
+ PrettyPrinter::print(
+ stats.sum_time /
std::max(static_cast<int64_t>(1), stats.rpc_count),
+ TUnit::TIME_NS),
+ PrettyPrinter::print(stats.sum_time, TUnit::TIME_NS));
detail_profile->add_info_string(out.str(), stats_str);
if (++i == count) {
break;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index e07d2213acf..77ce6068041 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -712,7 +712,7 @@ public class SessionVariable implements Serializable,
Writable {
public boolean enableProfile = false;
@VariableMgr.VarAttr(name = ENABLE_VERBOSE_PROFILE, needForward = true)
- public boolean enableVerboseProfile = true;
+ public boolean enableVerboseProfile = false;
@VariableMgr.VarAttr(name = RPC_VERBOSE_PROFILE_MAX_INSTANCE_COUNT,
needForward = true)
public int rpcVerboseProfileMaxInstanceCount = 5;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]