github-actions[bot] commented on code in PR #68652:
URL: https://github.com/apache/doris/pull/68652#discussion_r4214025900


##########
be/src/service/doris_main.cpp:
##########
@@ -662,11 +670,38 @@ int main(int argc, char** argv) {
     doris::ThriftRpcHelper::setup(exec_env);
     // 1. thrift server with be_port
     std::shared_ptr<doris::BaseBackendService> service;
+    std::unique_ptr<doris::server::IServerStarter> backend_thrift_starter;
+    std::unique_ptr<doris::server::IServerStarter> brpc_starter;
+    std::unique_ptr<doris::server::IServerStarter> http_starter;
+    std::unique_ptr<doris::server::IServerStarter> heartbeat_thrift_starter;
+    std::unique_ptr<doris::server::IServerStarter> flight_starter;
+    bool backend_thrift_started = false;
+    bool brpc_started = false;
+    bool http_started = false;
+    bool heartbeat_thrift_started = false;
+    bool flight_started = false;
+    auto stop_and_join_server = 
[](std::unique_ptr<doris::server::IServerStarter>& starter,
+                                   bool started) {
+        if (starter != nullptr) {
+            if (started) {
+                starter->stop();
+            }
+            starter->join();
+        }
+    };
     std::function<void(Status&, std::string_view)> stop_work_if_error = 
[&](Status& status,
                                                                             
std::string_view msg) {
         if (!status.ok()) {
             std::cerr << msg << '\n';
             service->stop_works();
+            if (doris::config::enable_graceful_exit_check) {
+                stop_and_join_server(flight_starter, flight_started);
+                stop_and_join_server(heartbeat_thrift_starter, 
heartbeat_thrift_started);
+                stop_and_join_server(http_starter, http_started);

Review Comment:
   [P2] Drain active HTTP stream loads before deleting their handlers. A 
PARQUET or ORC stream load admitted after HTTP starts can submit an async 
fragment whose callback captures raw `StreamLoadAction*` and `HttpRequest*`; 
this path resets `body_sink`, so request cleanup cannot cancel the fragment. If 
heartbeat or Flight startup then fails, this stop call frees the request after 
a bounded async-reply wait and deletes its handler before `ExecEnv::destroy()` 
drains `FragmentMgr`. A later fragment completion calls `_on_finish()` through 
those dangling pointers and can crash the BE. Stop admission and drain or 
cancel callbacks while their HTTP owners are still alive.



##########
be/src/service/doris_main.cpp:
##########
@@ -662,11 +670,38 @@ int main(int argc, char** argv) {
     doris::ThriftRpcHelper::setup(exec_env);
     // 1. thrift server with be_port
     std::shared_ptr<doris::BaseBackendService> service;
+    std::unique_ptr<doris::server::IServerStarter> backend_thrift_starter;
+    std::unique_ptr<doris::server::IServerStarter> brpc_starter;
+    std::unique_ptr<doris::server::IServerStarter> http_starter;
+    std::unique_ptr<doris::server::IServerStarter> heartbeat_thrift_starter;
+    std::unique_ptr<doris::server::IServerStarter> flight_starter;
+    bool backend_thrift_started = false;
+    bool brpc_started = false;
+    bool http_started = false;
+    bool heartbeat_thrift_started = false;
+    bool flight_started = false;
+    auto stop_and_join_server = 
[](std::unique_ptr<doris::server::IServerStarter>& starter,
+                                   bool started) {
+        if (starter != nullptr) {
+            if (started) {
+                starter->stop();
+            }
+            starter->join();
+        }
+    };
     std::function<void(Status&, std::string_view)> stop_work_if_error = 
[&](Status& status,
                                                                             
std::string_view msg) {
         if (!status.ok()) {
             std::cerr << msg << '\n';
             service->stop_works();
+            if (doris::config::enable_graceful_exit_check) {
+                stop_and_join_server(flight_starter, flight_started);
+                stop_and_join_server(heartbeat_thrift_starter, 
heartbeat_thrift_started);
+                stop_and_join_server(http_starter, http_started);

Review Comment:
   [P2] Join detached manual compactions before clearing HTTP handlers. In 
local mode, a base or cumulative compaction request starts a detached task that 
captures `CompactionAction*` and waits only two seconds for its result. If 
heartbeat or Flight startup then fails, this new HTTP stop deletes the action 
from its pool without joining that task; a delayed task can subsequently enter 
`_execute_compaction_callback()` and read `_engine` through the freed handler. 
Track and drain these tasks before destroying the HTTP handler pool and 
`ExecEnv`.



-- 
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]

Reply via email to