hello-stephen commented on code in PR #71336:
URL: https://github.com/apache/doris/pull/71336#discussion_r4784840255
##########
be/src/runtime/fragment_mgr.cpp:
##########
@@ -598,41 +606,67 @@ std::string FragmentMgr::dump_pipeline_tasks(int64_t
duration) {
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
- _pipeline_map.apply([&](phmap::flat_hash_map<std::pair<TUniqueId, int>,
-
std::shared_ptr<PipelineFragmentContext>>& map)
- -> Status {
+ _pipeline_map.apply(
+ [&](phmap::flat_hash_map<std::pair<TUniqueId, int>,
+
std::shared_ptr<PipelineFragmentContext>>& map) -> Status {
+ auto& entries = shard_entries.emplace_back();
+ for (auto& it : map) {
+ auto elapsed = it.second->elapsed_time() / 1000000000;
+ if (elapsed < duration) {
+ // Only display tasks which has been running for
more than {duration} seconds.
+ continue;
+ }
+ entries.push_back({it.first.first, it.second,
elapsed});
+ }
+ return Status::OK();
+ });
+
+ // Rendering can acquire RF context locks and task locks. Do not hold
a shard
+ // lock here: RF publish failure can cancel a query and remove its
fragments.
+ for (const auto& entries : shard_entries) {
std::set<TUniqueId> query_id_set;
- for (auto& it : map) {
- auto elapsed = it.second->elapsed_time() / 1000000000;
- if (elapsed < duration) {
- // Only display tasks which has been running for more than
{duration} seconds.
- continue;
+ for (const auto& entry : entries) {
+ std::shared_ptr<QueryContext> query_ctx;
+ std::string task_debug_string;
+ int timeout_second;
+ bool is_timeout;
+ {
+ auto pfc = entry.pfc.lock();
+ // A fragment may naturally retire after the shard
snapshot was taken.
+ if (!pfc) {
+ continue;
+ }
+ timeout_second = pfc->timeout_second();
+ is_timeout = pfc->is_timeout(now);
+ task_debug_string = pfc->debug_string();
+ if (query_id_set.insert(entry.query_id).second) {
+ query_ctx = pfc->get_query_ctx()->shared_from_this();
+ }
}
- if (!query_id_set.contains(it.first.first)) {
- query_id_set.insert(it.first.first);
- fmt::format_to(
- debug_string_buffer, "QueryId: {},
global_runtime_filter_mgr: {}\n",
- print_id(it.first.first),
-
it.second->get_query_ctx()->runtime_filter_mgr()->debug_string());
-
- if
(it.second->get_query_ctx()->get_merge_controller_handler()) {
- fmt::format_to(debug_string_buffer, "{}\n",
- it.second->get_query_ctx()
- ->get_merge_controller_handler()
- ->debug_string());
+ // In particular, do not retain a PFC while waiting for RF
diagnostics:
+ // a recursive CTE WAIT_FOR_DESTROY response depends on its
destruction.
+ if (query_ctx) {
+ std::string rf_debug_string;
+ {
+ // A local merger snapshot may release the previous
round's last Bloom
+ // reference, so keep the query limiter active until
debug_string returns.
+
SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(query_ctx->query_mem_tracker());
+ rf_debug_string =
query_ctx->runtime_filter_mgr()->debug_string();
Review Comment:
[P2] Initialize local runtime-filter stages before publishing them
This dump can release a round-N fragment before reading its query-level
runtime filters. `WAIT_FOR_DESTROY` can then complete and the same fragment's
`REBUILD` can register filters while this call is in flight. The old shard lock
prevented that overlap for a dump of the retiring fragment.
`register_local_merge_producer_filter()` inserts the replacement context at
`runtime_filter_mgr.cpp:299`, then writes the merger's plain `_stage` at line
313 after unlocking. The dump can print stage 0 for the round-N+1 merger or
race the write. Query-level consumer registration has the same ordering at
`runtime_state.cpp:715–726`. Set each stage before inserting the new object
into the manager's map and remove the later per-producer merger stage write.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]