db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Suresh Thalamati <tsur...@Source-Zone.org>
Subject [PATCH] for Derby-32; (Multiple jvm's booting the same database in parallel bug )
Date Thu, 07 Oct 2004 22:00:21 GMT

Patch to fix following two issues reported in Derby-32:
1)   Exclusive file lock on dbex.lck  is  getting released before the
database is shutdown, allowing  multiple jvm's to boot the same database
in parallel
2)  Exclusive file lock on dbex.lck  is not released even when database
is shutdown.


Thanks
-suresh


Index:
java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java

===================================================================

---
java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java   
(revision 53902)

+++
java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java   
(working copy)

@@ -168,6 +168,7 @@

 
     // lock against other JBMS opening the same database
     private StorageRandomAccessFile fileLockOnDB;
+    private StorageFile exFileLock; //file handle to get exclusive lock
     private HeaderPrintWriter istream;
     private static final String LINE =
     "----------------------------------------------------------------";
@@ -1702,7 +1703,7 @@

             //about applying exclusive file lock mechanism
             if(!throwDBlckException)
             {
-                StorageFile exFileLock = storageFactory.newStorageFile(
DB_EX_LOCKFILE_NAME);
+                exFileLock = storageFactory.newStorageFile(
DB_EX_LOCKFILE_NAME);
                 exLockStatus = exFileLock.getExclusiveFileLock();
             }
 
@@ -1804,10 +1805,15 @@

 
         if( storageFactory != null)
         {
-            StorageFile fileLock = storageFactory.newStorageFile(
DB_LOCKFILE_NAME);
+            StorageFile fileLock =
storageFactory.newStorageFile(DB_LOCKFILE_NAME);
+            fileLock.delete();
+        }
 
-            fileLock.releaseExclusiveFileLock();
-        }
+        //release the lock that is acquired using tryLock() to prevent
+        //multiple jvm booting the same database on Unix environments.
+        if(exFileLock != null)
+            exFileLock.releaseExclusiveFileLock();
+
         return;
     } // end of privReleaseJBMSLockOnDB
        


Mime
View raw message