|
20 | 20 | import org.apache.doris.qe.ConnectContext; |
21 | 21 | import org.apache.doris.qe.ConnectContext.ConnectType; |
22 | 22 | import org.apache.doris.qe.ConnectPoolMgr; |
| 23 | +import org.apache.doris.service.arrowflight.results.FlightSqlChannel; |
23 | 24 |
|
24 | 25 | import com.google.common.collect.Maps; |
25 | 26 | import org.apache.logging.log4j.LogManager; |
@@ -55,10 +56,24 @@ public int registerConnection(ConnectContext ctx) { |
55 | 56 |
|
56 | 57 | @Override |
57 | 58 | public void unregisterConnection(ConnectContext ctx) { |
| 59 | + // All Flight SQL session teardown paths (idle/query timeout, bearer token expiry, and |
| 60 | + // explicit CloseSession) reach here. Release channel-cached Arrow results before removing |
| 61 | + // the context from the pool. |
| 62 | + FlightSqlChannel flightSqlChannel = ctx.getFlightSqlChannel(); |
| 63 | + if (flightSqlChannel != null) { |
| 64 | + try { |
| 65 | + flightSqlChannel.close(); |
| 66 | + } catch (Throwable t) { |
| 67 | + // RootAllocator.close() marks the allocator closed before it reports outstanding |
| 68 | + // bytes. The error is actionable, but session teardown must still release the |
| 69 | + // coordinator, transaction and pool/token bookkeeping below. |
| 70 | + LOG.warn("failed to close Flight SQL channel while unregistering connection {}, peer identity {}", |
| 71 | + ctx.getConnectionId(), ctx.getPeerIdentity(), t); |
| 72 | + } |
| 73 | + } |
58 | 74 | // Finalize any Arrow Flight query whose coordinator was kept alive across the |
59 | 75 | // GetFlightInfo -> DoGet phases (see #62259), releasing its resources (e.g. external-table |
60 | | - // batch SplitSources and the query queue slot) when the connection is torn down: idle/query |
61 | | - // timeout, bearer token expiry, or explicit CloseSession all reach here. |
| 76 | + // batch SplitSources and the query queue slot). |
62 | 77 | ctx.closeFlightSqlDeferredExecutors(); |
63 | 78 | ctx.closeTxn(); |
64 | 79 | if (connectionMap.remove(ctx.getConnectionId()) != null) { |
|
0 commit comments