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

   ### 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
   
   master (`bb33ea1dbd`). Reproduced on branch-4.1 (`10e3ba56a0`), built from 
source.
   
   ### What's Wrong?
   
   With `enable_parallel_result_sink=true`, an Arrow Flight query gets one 
result endpoint on each result BE. When the query fails on one BE, its other 
endpoints are never told. A client reading them gets that BE's complete share 
of the result with no error, or a generic cancellation if an early-close cancel 
reaches the BE first. It never gets the query's error.
   
   The path on master:
   
   1. For an Arrow Flight query the FE closes the coordinator right after 
dispatch and returns, because the client pulls results from the BEs later 
(`fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java:1923-1955`, 
close at `:2073`). The query's backends are kept only in 
`FlightSqlQueryCancellation`, for the early-close path.
   2. The BE where the query fails reports the error to the FE (`report error 
status: … to coordinator`).
   3. `QeProcessorImpl.reportExecStatus` no longer finds the query 
(`fe/fe-core/src/main/java/org/apache/doris/qe/QeProcessorImpl.java`, the `info 
== null` branch around line 316) and returns OK. The failure is dropped.
   4. Nothing cancels the query on the other BEs. Their fragments run to 
completion, and their result buffers finish normally.
   
   ### What You Expected?
   
   When a query fails on one BE, every endpoint of the query should fail with 
the query's original error, as a MySQL-protocol query does.
   
   A possible fix: when `reportExecStatus` gets a non-OK status for a query 
whose Arrow Flight coordinator was released, cancel the query with that status 
on the backends `FlightSqlQueryCancellation` already keeps for it. Then each 
BE's result buffer returns the original error to `DoGet`.
   
   ### How to Reproduce?
   
   1 FE, 2 BEs, `enable_parallel_result_sink=true`.
   
   ```sql
   CREATE TABLE t2 (k BIGINT, v STRING) DISTRIBUTED BY HASH(k) BUCKETS 16 
PROPERTIES ("replication_num" = "1");
   INSERT INTO t2 SELECT number, repeat('x', 100) FROM numbers("number" = 
"200000");
   ```
   
   Note which BE holds `k = 12345`. Then, through Flight SQL (for example 
pyarrow or ADBC):
   
   ```sql
   SELECT t.k, assert_true(t.k != 12345, 'boom 12345'), n.number
   FROM t2 t CROSS JOIN [broadcast] (SELECT number FROM numbers("number" = 
"1000")) n;
   ```
   
   Read the endpoint on the BE that holds `k = 12345` until it fails, then read 
the endpoint on the other BE.
   
   Over 27 attempts:
   - The first endpoint returned `boom 12345` every time.
   - The other endpoint returned no error 25 times, with 112,500,000 rows each 
time. That is all of its BE's rows, the same as if the query had succeeded.
   - The other 2 times it failed with `[INTERNAL_ERROR]no arrow schema for this 
query, maybe query has been canceled`. In those, the early-close cancel `Arrow 
Flight stream closed before EOF` reached that BE first.
   
   BE and FE logs for one attempt (be2 holds `k = 12345`):
   
   ```
   fe  19:18:36,659 StmtExecutor.handleQueryWithRetry(): Query 
7b3069fbe80641ae-893e61ab1a021e50 finished
   be2 19:18:36.985152 
PipelineFragmentContext::cancel|query_id=7b3069fbe80641ae-893e61ab1a021e50|fragment_id=2|reason=[INVALID_ARGUMENT]boom
 12345
   be2 19:18:36.986529 report error status: boom 12345 to coordinator: …, query 
id: 7b3069fbe80641ae-893e61ab1a021e50
   fe  (no further line for this query)
   be1 (no cancel for this query; its ResultBlockBuffer finishes with 
is_cancelled=false)
   ```
   
   ### Anything Else?
   
   Related: #69945 and #69996 (cancel a Flight query on all its BEs when a 
result stream closes early), and #70850. Those cover a client that stops 
reading; this one covers a query that fails on a BE after dispatch.
   
   We have a patch and can open a PR.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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