deniskuzZ commented on code in PR #5649:
URL: https://github.com/apache/hive/pull/5649#discussion_r2019054923
##########
ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java:
##########
@@ -1969,6 +1987,38 @@ public void close() throws IOException {
dynamicVars.clear();
}
+ private static void cleanUpAllSessionStates() {
+ ExecutorService cleanupExecutor = Executors.newCachedThreadPool();
+ try {
+ CompletableFuture<Void> allCleanupTasks =
CompletableFuture.allOf(sessionStates.stream()
+ .map(sessionState -> CompletableFuture.runAsync(() -> {
+ try {
+ LOG.info("Closing session state: {}",
sessionState.getSessionId());
+ sessionState.close();
+ } catch (IOException e) {
+ LOG.error("Problem closing session state", e);
+ }
+ }, cleanupExecutor).exceptionally(e -> {
+ LOG.error("Error closing session state", e);
+ return null;
+ })).toArray(CompletableFuture[]::new));
+ try {
+ allCleanupTasks.get(60, TimeUnit.SECONDS);
+ } catch (Exception e) {
+ LOG.error("Failed to close all session states", e);
+ }
+ } finally {
+ cleanupExecutor.shutdown();
Review Comment:
why do you need a graceful shutdown if at this point all tasks either
completed successfully or timed out?
--
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]