svn commit: r1088875 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1088875 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java

jonesde
Author: jonesde
Date: Tue Apr  5 03:32:07 2011
New Revision: 1088875

URL: http://svn.apache.org/viewvc?rev=1088875&view=rev
Log:
Added code to keep track of where transactions are suspended to help diagnose lock wair timeout types of errors; also small cleanup with new getSuspendedTxStack instead of that code duplicated for each method

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java?rev=1088875&r1=1088874&r2=1088875&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/transaction/TransactionUtil.java Tue Apr  5 03:32:07 2011
@@ -65,6 +65,7 @@ public class TransactionUtil implements
     public static boolean debugResources = true;
 
     private static ThreadLocal<List<Transaction>> suspendedTxStack = new ThreadLocal<List<Transaction>>();
+    private static ThreadLocal<List<Exception>> suspendedTxLocationStack = new ThreadLocal<List<Exception>>();
     private static ThreadLocal<Exception> transactionBeginStack = new ThreadLocal<Exception>();
     private static ThreadLocal<List<Exception>> transactionBeginStackSave = new ThreadLocal<List<Exception>>();
     private static Map<Long, Exception> allThreadsTransactionBeginStack = Collections.<Long, Exception>synchronizedMap(FastMap.<Long, Exception>newInstance());
@@ -581,19 +582,29 @@ public class TransactionUtil implements
     }
     public static boolean suspendedTransactionsHeld() {
         List<Transaction> tl = suspendedTxStack.get();
-        if (UtilValidate.isNotEmpty(tl)) {
-            return true;
-        } else {
-            return false;
-        }
+        return UtilValidate.isNotEmpty(tl);
     }
-    protected static void pushSuspendedTransaction(Transaction t) {
+    public static List<Transaction> getSuspendedTxStack() {
         List<Transaction> tl = suspendedTxStack.get();
         if (tl == null) {
             tl = new LinkedList<Transaction>();
             suspendedTxStack.set(tl);
         }
+        return tl;
+    }
+    public static List<Exception> getSuspendedTxLocationsStack() {
+        List<Exception> tl = suspendedTxLocationStack.get();
+        if (tl == null) {
+            tl = new LinkedList<Exception>();
+            suspendedTxLocationStack.set(tl);
+        }
+        return tl;
+    }
+    protected static void pushSuspendedTransaction(Transaction t) {
+        List<Transaction> tl = getSuspendedTxStack();
         tl.add(0, t);
+        List<Exception> stls = getSuspendedTxLocationsStack();
+        stls.add(0, new Exception("TX Suspend Location"));
         // save the current transaction start stamp
         pushTransactionStartStamp(t);
     }
@@ -602,6 +613,8 @@ public class TransactionUtil implements
         if (UtilValidate.isNotEmpty(tl)) {
             // restore the transaction start stamp
             popTransactionStartStamp();
+            List<Exception> stls = suspendedTxLocationStack.get();
+            if (UtilValidate.isNotEmpty(stls)) stls.remove(0);
             return tl.remove(0);
         } else {
             return null;
@@ -611,6 +624,8 @@ public class TransactionUtil implements
         List<Transaction> tl = suspendedTxStack.get();
         if (UtilValidate.isNotEmpty(tl)) {
             tl.remove(t);
+            List<Exception> stls = suspendedTxLocationStack.get();
+            if (UtilValidate.isNotEmpty(stls)) stls.remove(0);
             popTransactionStartStamp(t);
         }
     }