Hi all!

The generatedUniqueTxId() method in FileResourceManager uses
System.currentTimeMillis() to generate txId's.

On my system it causes duplicate txId generation and FRM failure. I have
4 threads accessing one FRM instance.

This simple patch adds "salt" to it, with a little overhead to solve
this problem.


tx
~t~



Index:
/home/cstamas/worx/projects/ext/eclipse/commons-transaction/src/java/org/apache/commons/transaction/file/FileResourceManager.java
===================================================================
---
/home/cstamas/worx/projects/ext/eclipse/commons-transaction/src/java/org/apache/commons/transaction/file/FileResourceManager.java
   
(revision 348140)
+++
/home/cstamas/worx/projects/ext/eclipse/commons-transaction/src/java/org/apache/commons/transaction/file/FileResourceManager.java
   
(working copy)
@@ -144,6 +144,9 @@
     protected static final String WORK_DELETE_DIR = "delete";
 
     protected static final String CONTEXT_FILE = "transaction.log";
+   
+    // XXX used in txId generation
+    protected static long salt = 1;
 
     /*
      * --- Static helper methods ---
@@ -884,7 +887,8 @@
         String txId;
         synchronized (globalTransactions) {
             do {
-                txId = Long.toHexString(System.currentTimeMillis());
+                // XXX to prevent same txId generation on heavy load
+                txId = Long.toHexString(System.currentTimeMillis() +
salt++);
                 // XXX busy loop
             } while (getContext(txId) != null);
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to