mortalBibo opened a new issue, #62230:
URL: https://github.com/apache/doris/issues/62230

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### Version
   
   3.0.6
   
   ### What's Wrong
   
   When executing a large partition scan query on internal tables stored on 
S3/OSS (cloud storage-compute separation mode), if the query times out or is 
cancelled, the S3 read operations are **not terminated**. This causes scanner 
threads to remain blocked on S3 I/O, eventually exhausting the scanner thread 
pool and blocking all subsequent queries and Stream Load jobs.
   
   **Root cause**: `OlapScanner` (internal table scanner) does not propagate 
query cancellation to the `IOContext` used by the I/O layer, unlike 
`FileScanner` (external table scanner) which correctly overrides `try_stop()` 
to set `io_ctx->should_stop = true`.
   
   Specifically:
   1. `S3FileReader::read_at_impl()` completely ignores the `io_ctx` parameter 
(parameter name is commented out: `const IOContext* /*io_ctx*/`)
   2. `CachedRemoteFileReader::read_at_impl()` does not check cancellation in 
the FileBlock wait loop
   3. `OlapScanner` does not override `try_stop()` to propagate cancellation to 
IOContext
   
   ### Cascade failure chain
   
   ```
   Large cold scan on S3 → query timeout → cancel signal sent
     → Scanner threads blocked in S3 I/O, cannot respond to cancel
     → S3 retry loop sleeps up to ~10s without checking cancel
     → FileBlock wait causes thread pile-up
     → Scanner thread pool exhausted
     → All subsequent queries blocked
     → Stream Load jobs blocked
     → Cluster appears frozen (low CPU, high I/O)
   ```
   
   ### How to Reproduce
   
   1. Set up a Doris cluster in cloud storage-compute separation mode (S3/OSS 
backend)
   2. Create a partitioned table with several years of historical data
   3. Execute a large scan: `SELECT sum(col) FROM table WHERE dt >= 
'2021-01-01'`
   4. Wait for the query to timeout or manually `KILL QUERY`
   5. Immediately try to execute a small query — it will be blocked
   6. Check Stream Load — jobs will also be blocked
   
   ### Expected Behavior
   
   After query cancellation/timeout, scanner threads should detect the 
cancellation and release back to the thread pool promptly, without waiting for 
all in-flight S3 I/O operations to complete.
   
   ### Proposed Fix
   
   Add `RuntimeState*` to `IOContext` and check `runtime_state->is_cancelled()` 
in:
   1. `S3FileReader::read_at_impl()` retry loop
   2. `CachedRemoteFileReader::read_at_impl()` FileBlock wait loop
   
   This is a ~11 line change across 4 files. `RuntimeState*` is already 
available in `BetaRowsetReader::get_segment_iterators()` where IOContext is 
initialized.
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!


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