morrySnow opened a new pull request, #70064:
URL: https://github.com/apache/doris/pull/70064
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary:
A MySQL connection can enter the connection pool and then fail while sending
its login response, before its close listener is installed. Cleanup then closes
the channel without unregistering the pool entry. A rejected connection task
can also skip cleanup if sending its error response throws. Flight teardown has
a separate ownership cycle: the protocol adapter calls pool unregistration,
which releases protocol resources and rolls back transactions.
This first stage moves lifecycle coordination into ConnectContext:
- Introduce INITIALIZING, ACTIVE, CLOSING and CLOSED, with activation and
registration coordinated against closure.
- Make ConnectPoolMgr maintain registration, indexes and quotas only; remove
entries by matching the context instance.
- Route MySQL disconnects, Flight CloseSession, KILL CONNECTION,
initialization failures and idle expiry through idempotent cleanup.
- Revoke admission and cancel execution when closure starts, then release
session resources after existing protocol operations exit. Flight keeps its
deferred-executor handoff protection while delaying Arrow allocator release
until the running command exits.
- Bind the closing context during cleanup and restore the caller's binding,
including follower transaction rollback.
- Coordinate idle expiry with command admission, retain query-only
cancellation, and preserve wait_timeout for incomplete MySQL packet reads.
Internal task/HTTP owned and borrowed scopes, cross-FE orphan reclamation
and reliable remote cleanup retries remain separate work. Existing transaction
and temporary-table cleanup hooks retain their error handling; uncaught cleanup
failures are exposed through the completion result without publishing CLOSED.
The PR includes the lifecycle design document and focused tests for
initialization/response failures, registration/closure races, repeated and
reentrant cleanup, caller thread-local preservation, timeout behavior and
Flight buffer lifetime.
### Release note
Clean up failed client sessions reliably and defer Flight session buffer
release until running commands exit.
### Check List (For Author)
- Test
- [ ] Regression test
- [x] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
Validation on the submitted implementation:
- `./run-fe-ut.sh --run` with 9 selected classes: **115 tests passed**, 0
failures, 0 errors, 0 skipped; the full script returned BUILD SUCCESS.
- Classes: ConnectContextLifecycleTest, AcceptListenerTest,
ConnectPoolMgrTest, ConnectContextTest, FlightProtocolAdapterTest,
FlightSessionsInConnectPoolTest, DorisFlightSqlProducerTest,
ConnectionExceedTest and MetricsTest.
- `mvn -f fe/pom.xml checkstyle:check -pl fe-core`: passed.
- `git diff --check`: passed.
- Cluster SQL regression tests were not run.
- Behavior changed:
- [ ] No.
- [x] Yes. Client teardown rejects new commands after closure starts,
revokes registration once, and waits for existing operations to exit before
final resource release.
- Does this need documentation?
- [ ] No.
- [x] Yes. Included [ConnectContext lifecycle and refactoring
design](https://github.com/morrySnow/incubator-doris/blob/codex/connect-context-lifecycle/docs/connect-context-lifecycle.md),
including the implementation scope, validation and remaining work.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]