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

   ### What problem does this PR solve?
   
   Issue Number: #67577
   
   Related PR: #67966 (the Flight session teardown contract this keeps, D-13)
   
   Problem Summary:
   
   Stage 3, item 1 of #67577 (connection governance): one connection pool for 
both protocols.
   
   Arrow Flight SQL sessions lived in a pool of their own, 
`FlightSqlConnectPoolMgr`, held to `arrow_flight_max_connections` alone: not to 
`qe_max_connection`, not to the user's `max_user_connections`, refused with a 
sentence of their own ("the number of arrow flight bearer tokens should be 
equal to arrow flight sql max connections"), and summed into every 
scheduler-wide answer — the processlist, `KILL`, the timeout checker, the 
connection metrics — by `ConnectScheduler` walking two pools.
   
   There is one pool now:
   
   - `ConnectPoolMgr` registers a connection of either protocol against 
`qe_max_connection` and the user's `max_user_connections`, and a Flight session 
additionally against its sub-quota. It indexes Flight sessions by their peer 
identity (the bearer token), since that is how Flight requests name their 
session. `FlightSqlConnectPoolMgr` is deleted; `ConnectScheduler` delegates to 
the one pool.
   - `unregisterConnection` is where every teardown path of a connection meets 
— a MySQL channel closing, a Flight token expiring or being evicted, 
`CloseSession`, `KILL`, the timeout checker — so it is where the protocol 
releases what it still holds for the session, through the new 
`ProtocolAdapter.releaseSession`: for Flight the channel-cached results and the 
deferred query coordinators (`FlightProtocolAdapter.tearDown`, unchanged from 
#67966), nothing for MySQL. The transitional `ProtocolAdapter.connectPool` goes.
   - A Flight session refused for a limit is refused in the words a MySQL 
client is refused in (`Reach limit of connections. Total: %d, User: %d, 
Current: %d`, naming the Flight sub-quota only when it is the tighter one), as 
the `RESOURCE_EXHAUSTED` status of the request that would have opened it, and 
its bearer token is invalidated with the refusal.
   - `arrow_flight_max_connections` becomes the sub-quota of Flight sessions 
within the pool: `-1`, the new default, follows `qe_max_connection`; an 
explicit value never exceeds it. `connection_max` reports the pool's limit, 
`arrow_flight_connection_total` / `arrow_flight_connection_max` the Flight 
share of it. The token cache is sized from the effective sub-quota and is 
otherwise untouched: the token's lifecycle is the next PR's.
   
   ### Release note
   
   Arrow Flight SQL sessions and MySQL connections now share one connection 
pool: a Flight session counts against `qe_max_connection` and the user's 
`max_user_connections` like a MySQL connection, appears with them in `SHOW 
PROCESSLIST` and the connection metrics, and is refused for a limit with the 
same message as a MySQL connection (as the `RESOURCE_EXHAUSTED` status of the 
request that would have opened it). `arrow_flight_max_connections` is now a 
sub-quota of Flight sessions within that pool; its default changes from 4096 to 
-1 (follow `qe_max_connection`), and an explicit value is capped at 
`qe_max_connection`. `connection_max` now reports `qe_max_connection` alone 
instead of the sum of the two settings.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
   
     **Unit tests.** `ConnectPoolMgrTest` (new): both protocols against one 
limit; one user's limit counted across both, with nothing of a refused 
registration lingering; the Flight sub-quota within the pool's limit, its 
defaulting and cap; the refusal worded the same for both protocols and naming 
the sub-quota only when it is the tighter one; unregister releasing the 
protocol session before any bookkeeping, even for a session never registered; a 
Flight session's peer identity leaving the index with it. 
`ConnectionExceedTest`: the Flight refusal is the `RESOURCE_EXHAUSTED` status 
with the MySQL wording and invalidates the token. `FlightProtocolAdapterTest`: 
`releaseSession` finalizes the deferred executors and is idempotent; `KILL` 
unregisters the session and its peer identity from the one pool. `MetricsTest`: 
the connection gauges read the pool. `FlightSessionOptionsTest` (in-process FE, 
real Flight sessions) unchanged and green. Protocol goldens 
`MysqlPacketGoldenTest` (33 cases) /
  `FlightResultGoldenTest` (9 statements) unchanged.
   
     **Regression.** `arrow_flight_sql_p0/test_connection_quota` (new): a user 
with `max_user_connections = 4` — three MySQL connections and a Flight session 
fill the four; the next Flight session and the next MySQL connection are 
refused, in the same words and naming the same pool limit; `CloseSession` frees 
the slot for a MySQL connection, and closing that one frees it for a Flight 
session. (Four rather than one because the token manager still keeps at most 
`max_user_connections / 2` bearer tokens per user and evicts the oldest session 
with the token; that cache goes with the next PR.) Whole `arrow_flight_sql_p0` 
green locally: 11 suites, 0 failed, against an FE built from this branch.
   
   - Behavior changed:
       - [x] Yes. A Flight session is now held to `qe_max_connection` and the 
user's `max_user_connections`; the refusal's text and status change (the MySQL 
sentence as `RESOURCE_EXHAUSTED`, where it was an `INTERNAL` with a token-count 
sentence); the bearer token of a refused session is invalidated. 
`arrow_flight_max_connections` defaults to -1 (follow) and is capped at 
`qe_max_connection`. `connection_max` reports `qe_max_connection` instead of 
the sum with `arrow_flight_max_connections`.
   
   - Does this need documentation?
       - [x] Yes. The Arrow Flight SQL page and the FE config page: 
`arrow_flight_max_connections` semantics, and that Flight sessions count 
against `qe_max_connection` / `max_user_connections`.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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