matanper commented on issue #67578:
URL: https://github.com/apache/doris/issues/67578#issuecomment-7084526448

   A data point for the `PollFlightInfo` item: a design we have run and found 
to work.
   
   **Use case.** A Flight client wants a long query's progress, to show it or 
to enforce a scan budget. Today the only way is to poll 
`information_schema.backend_active_tasks` on a second connection. Each such 
poll is itself a statement that the FE plans and every BE answers, so under FE 
load it times out, exactly when progress matters most.
   
   **Design.** The FE overrides the standard `PollFlightInfo`. The feature is 
opt-in per session, behind a session variable that defaults to off. When it is 
off, the first poll is final, which is Arrow's default behaviour.
   
   - **First poll** of a `CommandStatementQuery` or 
`CommandPreparedStatementQuery`: runs it exactly as `GetFlightInfo` does. It 
returns the `FlightInfo` with its endpoints, so `DoGet` can start at once, plus 
a descriptor for the next poll.
   - **Later polls** with that descriptor: return the same `FlightInfo`, with 
progress so far in `app_metadata` as JSON: `query_id`, `scan_rows`, 
`scan_bytes`, `cpu_ms`, `elapsed_ms`, `finished`.
     - The counters come from the coordinator's merged BE runtime statistics 
(`WorkloadRuntimeStatusMgr`), so a poll costs no BE round trip.
     - `progress` (the 0–1 fraction) stays unset, because there is no total to 
divide by.
   - **End of the query:** the query is finished, and the response carries no 
next descriptor, once every BE it was sent to has reported it finished. It also 
ends if its statistics were reported and have since been purged.
   - **Answered immediately, never held.** Arrow Java's poll handler is 
synchronous, so holding a poll would tie up a gRPC thread per running query. 
The client paces its polls (about 1 s). Progress advances at the BE report 
interval.
   - **Isolation:** only the Flight session that ran the statement can poll it. 
Any other session gets `NOT_FOUND`. The poll token is a random UUID.
   - **Bounds:** an unpolled state expires after a mutable TTL (default 300 s). 
Expired states are swept lazily, `CloseSession` drops a session's states, and 
the number of states is capped.
   - **`GetFlightInfo`, `DoGet` and every other call are unchanged;** 
`PollFlightInfo` is purely additive.
   
   **Measured on a 10M-row VARIANT table with a `COUNT` scan:**
   - the first poll answered in 84 ms with the endpoint;
   - later polls showed 0 → 4.8M rows / 2.9 GB at about 4 s, then 10M rows / 
3.7 GB and `finished: true` at 6 s;
   - another session's poll got `NOT_FOUND`;
   - `DoGet` after polling returned the full result.
   
   The new early-close cancellation (#69945, #69996) pairs well with this. A 
client that sees a budget exceeded through `PollFlightInfo` can simply close 
its stream, and the query stops on every BE.
   


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