From 70d71b5576ca16bd3b6232cb01aae5e3b324ee91 Mon Sep 17 00:00:00 2001 From: Stefan CORDES <50696194+ca-stefan-cordes@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:12:23 +0100 Subject: [PATCH 1/2] Rollback all inflight transactions when shutting down to inform all resource holders (specially XA ones) nothing more will happen here. This avoids indoubt threads like V466-THREAD HAS BEEN INDOUBT FOR 27:25:58 V451-RESYNC WITH COORDINATOR STILL PENDING --- .../tm/BitronixTransactionManager.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java index 24114e4d..dec654de 100644 --- a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java +++ b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java @@ -370,13 +370,38 @@ private void internalShutdown() { if (txCount > 0) { if (log.isDebugEnabled()) log.debug("still " + txCount + " in-flight transactions, shutting down anyway"); dumpTransactionContexts(); + rollbackAllInFlightTransactions(); } else { if (log.isDebugEnabled()) log.debug("all transactions finished, resuming shutdown"); } } - public String toString() { + /** + * Rollback all inflight transactions when shutting down to inform all resource holders (specially XA ones) + * nothing more will happen here. + * This avoids indoubt threads like + *
+     *  V466-THREAD HAS BEEN INDOUBT FOR 27:25:58
+     *  V451-RESYNC WITH COORDINATOR STILL PENDING
+     * 
+ */ + private void rollbackAllInFlightTransactions() { + log.warn("Rollback all remaining "+inFlightTransactions.size()+" inFlightTransactions"); + for (Map.Entry entry : inFlightTransactions.entrySet()) { + BitronixTransaction tx = entry.getValue(); + try { + log.warn("Rollback Uid="+entry.getKey()+" inFlightTransaction="+tx.toString()); + tx.rollback(); + } catch (SystemException e) { + log.warn("Ignore Exception when rolling back during shutdown Uid="+entry.getKey()+" inFlightTransaction="+tx.toString()); + } + } + log.info("Rollback of remaining inFlightTransactions finished."); + inFlightTransactions.clear(); + } + + public String toString() { return "a BitronixTransactionManager with " + inFlightTransactions.size() + " in-flight transaction(s)"; } From b8afabe2b1ef57d7266bd934b1f026cf3efcd645 Mon Sep 17 00:00:00 2001 From: Stefan CORDES <50696194+ca-stefan-cordes@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:14:52 +0100 Subject: [PATCH 2/2] restore whitespaces for comparing --- btm/src/main/java/bitronix/tm/BitronixTransactionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java index dec654de..36cdd218 100644 --- a/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java +++ b/btm/src/main/java/bitronix/tm/BitronixTransactionManager.java @@ -401,7 +401,7 @@ private void rollbackAllInFlightTransactions() { inFlightTransactions.clear(); } - public String toString() { + public String toString() { return "a BitronixTransactionManager with " + inFlightTransactions.size() + " in-flight transaction(s)"; }