You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Suresh Thalamati <ts...@Source-Zone.org> on 2004/10/08 00:00:21 UTC
[PATCH] for Derby-32; (Multiple jvm's booting the same database
in parallel bug )
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