This is an automated email from the ASF dual-hosted git repository.

bobhan1 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 2763903be96 [fix](be) Fix WAL replay retry backoff overflow (#68834)
2763903be96 is described below

commit 2763903be964e3a814278001d0425c5a5f30d24d
Author: bobhan1 <[email protected]>
AuthorDate: Sat Oct 10 10:06:17 2026 +0800

    [fix](be) Fix WAL replay retry backoff overflow (#68834)
    
    ### What problem does this PR solve?
    
    Issue Number: N/A
    
    Related PR: N/A
    
    Problem Summary: Long-running WAL replay retries can lose their backoff
    because the linear delay is multiplied using 32-bit integers before the
    result is converted to `int64_t`. With the default configuration, retry
    count 1204 makes `(1204 - 10) * 1800 * 1000` exceed `INT32_MAX`,
    potentially causing replay on every background scan instead of every 30
    minutes.
    
    Promote the retry count to `int64_t` before subtraction and
    multiplication. This preserves the existing backoff formula while
    keeping the linear delay in 64-bit arithmetic.
    
    Move the `BE_TEST` bypass to the start of `WalTable::_need_replay()` so
    test builds return immediately before checking replay configuration,
    preserving immediate replay in test builds.
    
    ### Release note
    
    Fix WAL replay backoff overflow after prolonged retries.
    
    ### Check List (For Author)
    
    - Test:
        - [x] No need to test or manual test. Explain why:
    - [x] Other reason: Small arithmetic type promotion and a
    behavior-preserving cleanup of the test guard. No tests added at the
    user's request. No automated tests or full build run. No further
    clang-tidy runs at the user's request; the initial attempt could not
    analyze the file because the local toolchain could not find
    `emmintrin.h`.
    - Validation: `build-support/clang-format.sh` and
    `build-support/check-format.sh` passed with clang-format 16.0.6; `git
    diff --check` passed. Manually checked the default delay at retry counts
    1203, 1204, and 1205: 2,152,520,000, 2,154,320,000, and 2,156,120,000
    ms, respectively, retaining a 1,800,000 ms increment.
    - Behavior changed:
    - [x] Yes. Prolonged failed WAL replays retain the configured backoff
    after the previous 32-bit overflow boundary.
    - Does this need documentation?
        - [x] No.
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label
---
 be/src/load/group_commit/wal/wal_table.cpp | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/be/src/load/group_commit/wal/wal_table.cpp 
b/be/src/load/group_commit/wal/wal_table.cpp
index 69e5d7cf2b7..2b7db81b664 100644
--- a/be/src/load/group_commit/wal/wal_table.cpp
+++ b/be/src/load/group_commit/wal/wal_table.cpp
@@ -157,25 +157,24 @@ Status WalTable::replay_wals() {
 }
 
 bool WalTable::_need_replay(std::shared_ptr<WalInfo> wal_info) {
+#ifdef BE_TEST
+    return true;
+#endif
     if (config::group_commit_wait_replay_wal_finish) {
         return true;
     }
-#ifndef BE_TEST
     int64_t replay_interval = 0;
     if (wal_info->get_retry_num() >= 
config::group_commit_replay_wal_retry_num) {
-        replay_interval =
-                int64_t(pow(2, config::group_commit_replay_wal_retry_num) *
-                                
config::group_commit_replay_wal_retry_interval_seconds * 1000 +
-                        (wal_info->get_retry_num() - 
config::group_commit_replay_wal_retry_num) *
-                                
config::group_commit_replay_wal_retry_interval_max_seconds * 1000);
+        replay_interval = int64_t(
+                pow(2, config::group_commit_replay_wal_retry_num) *
+                        config::group_commit_replay_wal_retry_interval_seconds 
* 1000 +
+                (int64_t(wal_info->get_retry_num()) - 
config::group_commit_replay_wal_retry_num) *
+                        
config::group_commit_replay_wal_retry_interval_max_seconds * 1000);
     } else {
         replay_interval = int64_t(pow(2, wal_info->get_retry_num()) *
                                   
config::group_commit_replay_wal_retry_interval_seconds * 1000);
     }
     return UnixMillis() - wal_info->get_start_time_ms() >= replay_interval;
-#else
-    return true;
-#endif
 }
 
 Status WalTable::_try_abort_txn(int64_t db_id, std::string& label) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to