[Mulgara-svn] r1014 - branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver

ronald at mulgara.org ronald at mulgara.org
Mon Jun 23 02:49:41 UTC 2008


Author: ronald
Date: 2008-06-22 19:49:40 -0700 (Sun, 22 Jun 2008)
New Revision: 1014

Modified:
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransactionFactory.java
   branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraInternalTransactionFactory.java
Log:
Added some explicit comments explaining why the mutex is released before
certain operations.


Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransactionFactory.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransactionFactory.java	2008-06-23 02:42:45 UTC (rev 1013)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraExternalTransactionFactory.java	2008-06-23 02:49:40 UTC (rev 1014)
@@ -94,6 +94,7 @@
       }
 
       if (write) {
+          // see comment in MulgaraInternalTransactionFactory regarding releasing the lock here
           runWithoutMutex(new TransactionOperation() {
             public void execute() throws MulgaraTransactionException {
               manager.obtainWriteLock(session, MulgaraExternalTransactionFactory.this);

Modified: branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraInternalTransactionFactory.java
===================================================================
--- branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraInternalTransactionFactory.java	2008-06-23 02:42:45 UTC (rev 1013)
+++ branches/mgr-121-lockrecovery/src/jar/resolver/java/org/mulgara/resolver/MulgaraInternalTransactionFactory.java	2008-06-23 02:49:40 UTC (rev 1014)
@@ -98,6 +98,11 @@
       try {
         MulgaraInternalTransaction transaction;
         if (write) {
+          // We must release the mutex so that if the manager blocks trying to acquire the write
+          // lock then the client holding it can still enter here and release the lock (i.e. we
+          // end up acquiring two sets of mutexes, this one and the one in the manager, but the
+          // wait() in the manager only releases the second mutex, hence we must release this one
+          // ourselves first).
           runWithoutMutex(new TransactionOperation() {
             public void execute() throws MulgaraTransactionException {
               manager.obtainWriteLock(session, MulgaraInternalTransactionFactory.this);
@@ -231,6 +236,8 @@
           if (manager.isHoldingWriteLock(session)) {
             // Within active transaction - commit and finalise.
             try {
+              // Release mutex to avoid blocking everybody while the commit is in progress,
+              // since this can be a lengthy operations (several minutes)
               runWithoutMutex(new TransactionOperation() {
                 public void execute() throws MulgaraTransactionException {
                   writeTransaction.execute(new TransactionOperation() {




More information about the Mulgara-svn mailing list