From a9a03e668ce950a9a7428aac5e9e1d056ca0104f Mon Sep 17 00:00:00 2001 From: Stefan CORDES <50696194+ca-stefan-cordes@users.noreply.github.com> Date: Fri, 12 Nov 2021 13:01:48 +0100 Subject: [PATCH 1/2] Log inflightTransactions during shutdown to ensure open transactions to be found. --- .../tm/BitronixTransactionManager.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java index 24114e4d..e921b0fe 100644 --- a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java +++ b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java @@ -302,6 +302,17 @@ public void dumpTransactionContexts() { } // if } + /** + * Dump an overview of all running transactions as info logs. + */ + public void dumpTransactionContextsInfo() { + log.info("dumping " + inFlightTransactions.size() + " transaction context(s)"); + for (Map.Entry entry : inFlightTransactions.entrySet()) { + BitronixTransaction tx = entry.getValue(); + log.info(tx.toString()); + } + } + /** * Shut down the transaction manager and release all resources held by it. *

This call will also close the resources pools registered by the {@link bitronix.tm.resource.ResourceLoader} @@ -347,14 +358,14 @@ public synchronized void shutdown() { private void internalShutdown() { shuttingDown = true; - dumpTransactionContexts(); + dumpTransactionContextsInfo(); int seconds = TransactionManagerServices.getConfiguration().getGracefulShutdownInterval(); int txCount = 0; try { txCount = inFlightTransactions.size(); while (seconds > 0 && txCount > 0) { - if (log.isDebugEnabled()) log.debug("still " + txCount + " in-flight transactions, waiting... (" + seconds + " second(s) left)"); + log.info("still " + txCount + " in-flight transactions, waiting... (" + seconds + " second(s) left)"); try { Thread.sleep(1000); } catch (InterruptedException ex) { @@ -368,11 +379,11 @@ private void internalShutdown() { } if (txCount > 0) { - if (log.isDebugEnabled()) log.debug("still " + txCount + " in-flight transactions, shutting down anyway"); - dumpTransactionContexts(); + log.info("still " + txCount + " in-flight transactions, shutting down anyway"); + dumpTransactionContextsInfo(); } else { - if (log.isDebugEnabled()) log.debug("all transactions finished, resuming shutdown"); + log.info("all transactions finished, resuming shutdown"); } } From f16a4eeb5367e5a78759ad1ed19cac6a97e82d9b Mon Sep 17 00:00:00 2001 From: Stefan CORDES <50696194+ca-stefan-cordes@users.noreply.github.com> Date: Wed, 16 Feb 2022 10:55:07 +0100 Subject: [PATCH 2/2] log all shutdown steps as it is not clear whether it hangs on internalShutdown --- .../bitronix/tm/BitronixTransactionManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java index e921b0fe..f0707954 100644 --- a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java +++ b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java @@ -332,28 +332,28 @@ public synchronized void shutdown() { log.info("shutting down Bitronix Transaction Manager"); internalShutdown(); - if (log.isDebugEnabled()) log.debug("shutting down resource loader"); + log.info("shutting down resource loader"); TransactionManagerServices.getResourceLoader().shutdown(); - if (log.isDebugEnabled()) log.debug("shutting down executor"); + log.info("shutting down executor"); TransactionManagerServices.getExecutor().shutdown(); - if (log.isDebugEnabled()) log.debug("shutting down task scheduler"); + log.info("shutting down task scheduler"); TransactionManagerServices.getTaskScheduler().shutdown(); - if (log.isDebugEnabled()) log.debug("shutting down journal"); + log.info("shutting down journal"); TransactionManagerServices.getJournal().shutdown(); - if (log.isDebugEnabled()) log.debug("shutting down recoverer"); + log.info("shutting down recoverer"); TransactionManagerServices.getRecoverer().shutdown(); - if (log.isDebugEnabled()) log.debug("shutting down configuration"); + log.info("shutting down configuration"); TransactionManagerServices.getConfiguration().shutdown(); // clear references TransactionManagerServices.clear(); - if (log.isDebugEnabled()) log.debug("shutdown ran successfully"); + log.info("shutdown ran successfully"); } private void internalShutdown() {