wenzhenghu commented on code in PR #68740:
URL: https://github.com/apache/doris/pull/68740#discussion_r4267286278


##########
be/src/storage/disk_health_check_watchdog.cpp:
##########
@@ -0,0 +1,128 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "storage/disk_health_check_watchdog.h"
+
+#include <unistd.h>
+
+#include <ctime>
+#include <limits>
+
+#include "common/check.h"
+#include "common/status.h"
+#include "util/time.h"
+
+namespace doris {
+
+static_assert(std::atomic<int64_t>::is_always_lock_free);
+static_assert(std::atomic<bool>::is_always_lock_free);
+
+DiskHealthCheckWatchdog::~DiskHealthCheckWatchdog() {
+    stop();
+}
+
+Status DiskHealthCheckWatchdog::start(std::chrono::milliseconds timeout) {
+    // NOLINTNEXTLINE(readability-inconsistent-ifelse-braces): DORIS_CHECK 
expands to if/else.
+    DORIS_CHECK(!_started && !_stopped.load(std::memory_order_acquire));
+    if (timeout.count() < 0 || timeout.count() > 
std::numeric_limits<int32_t>::max() * 1000LL) {
+        return Status::InvalidArgument("Invalid disk health check timeout: {} 
ms", timeout.count());
+    }
+    _timeout_ms = timeout.count();
+    if (_timeout_ms == 0) {
+        return Status::OK();
+    }
+    // Unlike ordinary Doris workers, this thread must work before ExecEnv is
+    // initialized and cannot depend on ThreadMgr locks or memory-tracker 
setup.
+    // Its callback neither allocates nor logs and needs no Doris thread 
context.
+    int err = pthread_create(

Review Comment:
   Addressed in 
[04d211fa61bd](https://github.com/apache/doris/commit/04d211fa61bdd16bc288a448379c0de6f97021d4).
 The poller is now named `disk-watchdog` at thread entry. Linux uses 
`prctl(PR_SET_NAME)` because Doris's glibc compatibility layer makes 
`pthread_setname_np` a no-op; macOS uses its pthread naming API. Naming is best 
effort and does not involve ThreadMgr/logging initialization.
   
   The runtime test verified the name in `/proc/<pid>/task/*/comm`, and 
verified that no watchdog thread exists with the default timeout `0`.



##########
be/src/storage/storage_engine.cpp:
##########
@@ -495,9 +495,15 @@ int64_t StorageEngine::get_file_or_directory_size(const 
std::string& file_path)
 
 void StorageEngine::_start_disk_stat_monitor() {
     for (auto& it : _store_map) {
+        // Include IO-error handling: persisting the broken path can also 
stall.
+        DiskHealthCheckWatchdog::ScopedCheck 
check(_disk_health_check_watchdog);
         it.second->health_check();
     }
 
+    // These steps acquire _store_lock and may log a fatal disk failure. Keep
+    // supervising them so a stalled report or fatal logger cannot stop probing
+    // forever after the last per-disk check has completed.
+    DiskHealthCheckWatchdog::ScopedCheck check(_disk_health_check_watchdog);

Review Comment:
   The scope remains intentional, and 
[04d211fa61bd](https://github.com/apache/doris/commit/04d211fa61bdd16bc288a448379c0de6f97021d4)
 now documents that a timeout takes precedence over a stalled fatal 
handler/core dump. Ending supervision before the fatal path would leave the 
original blocked-logging/termination problem unbounded.
   
   The PR guidance explicitly states the diagnostic trade-off: the timeout path 
is `_exit(74)` without logs or a core. This behavior remains opt-in, with 
timeout `0` by default.



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