[fix](runtime) Clear query_ctx_map_delay_delete in FragmentMgr::stop() to avoid UB (#60718)

Related PR: https://github.com/apache/doris/pull/59262

Problem Summary:

During BE graceful shutdown, cancel_worker cancels running queries via
_get_all_running_queries_from_fe, so clearing
_query_ctx_map_delay_delete here won't cause RF consumer to hang.
Without this clear, QueryContext destruction in ~FragmentMgr() may
attempt to remove itself from _query_ctx_map_delay_delete while the map
is being destructed, causing undefined behavior.

stack:
```
~FragmentMgr
    ~_query_ctx_map_delay_delete
        ~QueryContext
            FragmentMgr::remove_query_context
                _query_ctx_map_delay_delete.erase() ⚠️call function of object that is being destructed
```
This commit is contained in:
zclllyybb authored and GitHub committed 2026-02-13 09:58:16 +08:00
1 parent 90ffecd7fb
commit c137bd2088
1 file changed
+4
+4
View File
@@ -340,6 +340,10 @@ void FragmentMgr::stop() {
_thread_pool->shutdown();
// Only me can delete
_query_ctx_map.clear();
// in one BE's graceful shutdown, cancel_worker will get related running queries via _get_all_running_queries_from_fe and cancel them.
// so clearing here will not make RF consumer hang. if we dont do this, in ~FragmentMgr() there may be QueryContext in _query_ctx_map_delay_delete
// destructred and remove it from _query_ctx_map_delay_delete which is destructring. it's UB.
_query_ctx_map_delay_delete.clear();
_pipeline_map.clear();
}