github-actions[bot] commented on code in PR #69421:
URL: https://github.com/apache/doris/pull/69421#discussion_r4344816970
##########
fe/fe-core/src/main/java/org/apache/doris/arrowflight/results/FlightSqlChannel.java:
##########
@@ -118,6 +124,12 @@ public long resultNum() {
return resultCache.size();
}
+ public boolean hasPendingResults() {
+ // size() alone can count expired entries indefinitely on an idle
session.
+ resultCache.cleanUp();
+ return resultCache.size() > 0;
Review Comment:
[P2] Clear unpublished Flight results before waiting on the cache
`SHOW VARIABLES; SELECT 1` caches the SHOW result, then
`FlightProtocolAdapter.finishStatement()` rejects the nonfinal result.
`executeQueryStatement()` returns an error without issuing a ticket, but its
failure cleanup only cancels deferred BE executors and leaves this live FE
cache entry behind. If the client keeps the session open and shutdown follows,
`cleanUp()` cannot evict it before the 10-minute TTL, so this new predicate
forces the full default 300-second grace wait even after all
requests/coordinators finish. Clear the current request's cached result when
GetFlightInfo fails, or count only results with issued tickets. This differs
from the existing expired-entry issue because this result is still live and was
never published.
##########
fe/fe-core/src/main/java/org/apache/doris/DorisFE.java:
##########
@@ -726,19 +730,46 @@ public static boolean isServerReady() {
}
private static void gracefulShutdown() {
- // wait for all queries to finish
+ // Health is already 503, but keep serving during LB / DNS convergence.
+ try {
+ LOG.info("graceful shutdown: serving during drain for {} seconds",
Config.graceful_shutdown_drain_seconds);
+ TimeUnit.SECONDS.sleep(Math.max(0,
Config.graceful_shutdown_drain_seconds));
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ LOG.warn("graceful shutdown drain interrupted", e);
+ }
+
+ // Close admission before the listener: an accepted connection can
race its closure.
+ QueryAdmissionController.INSTANCE.stopAccepting();
+ if (qeService != null) {
+ qeService.stopAcceptNewConnections();
+ }
try {
- long now = System.currentTimeMillis();
- List<Coordinator> allCoordinators =
QeProcessorImpl.INSTANCE.getAllCoordinators();
- while (!allCoordinators.isEmpty() && System.currentTimeMillis() -
now < 300 * 1000L) {
- Thread.sleep(1000);
- allCoordinators =
QeProcessorImpl.INSTANCE.getAllCoordinators();
- LOG.info("waiting {} queries to finish before shutdown",
allCoordinators.size());
+ long deadline = System.nanoTime()
+ + TimeUnit.SECONDS.toNanos(Math.max(0,
Config.grace_shutdown_wait_seconds));
+ while (true) {
+
ExecuteEnv.getInstance().getScheduler().closeIdleMysqlConnections();
Review Comment:
[P2] Keep idle transaction teardown within the shutdown deadline
This scan can block on transaction rollback before reaching the deadline
check. `closeIdleMysqlConnection()` closes the XNIO connection, whose [close
listener runs
synchronously](https://github.com/xnio/xnio/blob/3.8.14.Final/api/src/main/java/org/xnio/Connection.java#L113-L134);
the listener calls `unregisterConnection()` -> `closeTxn()` ->
`TransactionEntry.abortTransaction()`. For an idle `BEGIN; INSERT INTO ...
VALUES ...` transaction, `InsertStreamTxnExecutor.abortTransaction()` waits up
to five seconds for the BE rollback RPC. A BE that keeps the channel open but
does not answer rollback can therefore add five seconds per idle session,
serially: 61 sessions exceed the default 300-second bound before the first
deadline check, and one exceeds a configured one-second bound. Move the
blocking teardown off the drain thread and bound it by the same shutdown
deadline.
--
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]