BiteTheDDDDt opened a new pull request, #62815:
URL: https://github.com/apache/doris/pull/62815

   Related PR: N/A
   
   Problem Summary:
   
   `CountedFinishDependency::sub()` decrements an unsigned `uint32_t _counter`
   without checking that the counter is greater than zero. The contract is that
   each `sub()` is balanced by a prior `add()`, but if the protocol is ever
   violated (e.g. a duplicated `sync_filter_size` RPC from FE, double callback
   on the BE side, or any future bug) the `0--` silently underflows to
   `UINT32_MAX`. The condition `if (!_counter) set_ready();` is then never true
   and the dependency stays blocked forever, hanging the entire query with no
   log line and no crash, making the bug very hard to diagnose.
   
   This is especially relevant because there are multiple callers of `sub()`:
   - `SyncSizeCallback::call()` on RPC failure
   - `SyncSizeCallback::call()` on RPC success but error response status
   - `RuntimeFilterProducer::set_synced_size()` triggered by FE
   
   Any imbalance between these and the single `add()` in
   `RuntimeFilterProducer::set_dependency()` would produce the silent hang.
   
   Add an explicit check at the top of `sub()` that throws an
   `Exception(ErrorCode::INTERNAL_ERROR, ...)` carrying `debug_string()` when
   `_counter == 0`. This matches the project convention of asserting
   correctness and failing fast rather than letting the process limp along in
   a corrupt state.
   
   ### Release note
   
   Fix a potential silent query hang caused by an unbalanced
   `CountedFinishDependency::sub()` call underflowing the counter. Such cases
   now throw an explicit `INTERNAL_ERROR` instead.
   
   ### Check List (For Author)
   
   - Test:
       - [x] Unit Test: added `CountedFinishDependencyTest` in
         `be/test/exec/runtime_filter/sync_size_callback_test.cpp` covering
         sub() on a fresh counter, sub() after balanced add/sub, and the happy
         path of multiple add() / sub() reaching ready. All pass.
       - [x] Existing `SyncSizeCallbackTest.*` re-run, no regression.
   
   - Behavior changed: No (the only observable change is converting an existing
     silent failure into a loud error when the contract is violated)
   
   - Does this need documentation: No
   


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