[
https://issues.apache.org/jira/browse/DERBY-5766?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13276966#comment-13276966
]
Kathey Marsden commented on DERBY-5766:
---------------------------------------
So even on Windows with cygwin I can chmod 444 the db.lck file and then get no
error or warning on connect and the read only message when I try to do
something.
connect 'jdbc:derby:wombat';
ij(CONNECTION1)> create table t ( i int);
ERROR 25503: DDL is not permitted for a read-only connection, user or database.
ij(CONNECTION1)> exit;
~/repro/derby-5766 $
The IOException that occurs on boot if I print it out with the permission
issue is:
java.io.FileNotFoundException:
C:\cygwin\home\kmarsden\repro\DERBY-5766\wombat\db.lck (Access is denied.)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:244)
at
org.apache.derby.impl.io.DirRandomAccessFile.<init>(DirRandomAccessFile.java:57)
at
org.apache.derby.impl.io.DirFile4.getRandomAccessFile(DirFile4.java:290)
at
org.apache.derby.impl.store.raw.data.BaseDataFileFactory.privGetJBMSLockOnDB(BaseDataFileFactory.java:1851)
at
org.apache.derby.impl.store.raw.data.BaseDataFileFactory.run(BaseDataFileFactory.java:2851)
at
java.security.AccessController.doPrivileged(AccessController.java:254)
at
org.apache.derby.impl.store.raw.data.BaseDataFileFactory.getJBMSLockOnDB(BaseDataFileFactory.java:1811)
at
org.apache.derby.impl.store.raw.data.BaseDataFileFactory.boot(BaseDataFileFactory.java:323)
at
org.apache.derby.impl.services.monitor.BaseMonitor.boot(BaseMonitor.java:1993)
at
org.apache.derby.impl.services.monitor.TopService.bootModule(TopService.java:334)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startModule(BaseMonitor.java:542)
at
org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Monitor.java:427)
at org.apache.derby.impl.store.raw.RawStore.boot(RawStore.java:189)
at
org.apache.derby.impl.services.monitor.BaseMonitor.boot(BaseMonitor.java:1993)
at
org.apache.derby.impl.services.monitor.TopService.bootModule(TopService.java:334)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startModule(BaseMonitor.java:542)
at
org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Monitor.java:427)
at
org.apache.derby.impl.store.access.RAMAccessManager.boot(RAMAccessManager.java:1019)
at
org.apache.derby.impl.services.monitor.BaseMonitor.boot(BaseMonitor.java:1993)
at
org.apache.derby.impl.services.monitor.TopService.bootModule(TopService.java:334)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startModule(BaseMonitor.java:542)
at
org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Monitor.java:427)
at
org.apache.derby.impl.db.BasicDatabase.bootStore(BasicDatabase.java:760)
at org.apache.derby.impl.db.BasicDatabase.boot(BasicDatabase.java:177)
at
org.apache.derby.impl.services.monitor.BaseMonitor.boot(BaseMonitor.java:1993)
at
org.apache.derby.impl.services.monitor.TopService.bootModule(TopService.java:334)
at
org.apache.derby.impl.services.monitor.BaseMonitor.bootService(BaseMonitor.java:1827)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(BaseMonitor.java:1693)
at
org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(BaseMonitor.java:1571)
at
org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(BaseMonitor.java:990)
at
org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Monitor.java:550)
at
org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:2767)
at
org.apache.derby.impl.jdbc.EmbedConnection.<init>(EmbedConnection.java:383)
at
org.apache.derby.impl.jdbc.EmbedConnection30.<init>(EmbedConnection30.java:73)
at
org.apache.derby.impl.jdbc.EmbedConnection40.<init>(EmbedConnection40.java:53)
at
org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Driver40.java:70)
at org.apache.derby.jdbc.InternalDriver.connect(InternalDriver.java:255)
at
org.apache.derby.jdbc.AutoloadedDriver.connect(AutoloadedDriver.java:143)
at java.sql.DriverManager.getConnection(DriverManager.java:590)
at java.sql.DriverManager.getConnection(DriverManager.java:201)
at org.apache.derby.impl.tools.ij.ij.dynamicConnection(ij.java:1528)
at org.apache.derby.impl.tools.ij.ij.ConnectStatement(ij.java:1358)
at org.apache.derby.impl.tools.ij.ij.ijStatement(ij.java:1143)
at
org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:347)
at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
at org.apache.derby.tools.ij.main(ij.java:59)
Alternately if I write a program to hold the file in a separate process, I get
a dual boot message instead.
> BaseDataFileFactory.boot() should log the exception that causes it to boot
> the database read only
> --------------------------------------------------------------------------------------------------
>
> Key: DERBY-5766
> URL: https://issues.apache.org/jira/browse/DERBY-5766
> Project: Derby
> Issue Type: Bug
> Components: Store
> Affects Versions: 10.9.0.0
> Reporter: Kathey Marsden
> Assignee: Kathey Marsden
>
> In BaseDataFileFactory.boot() there is code that tries to write to the lock
> file. If it cannot, and gets an IOException it assumes the database is read
> only. I think that we should log that the database is booting read only and
> why and if it is not specifically a permission error log the exception stack
> trace.
>
> fileLockOnDB = fileLock.getRandomAccessFile( "rw");
> fileLock.limitAccessToOwner();
> // write it out for future reference
> fileLockOnDB.writeUTF(myUUID.toString());
> fileLockOnDB.sync();
> fileLockOnDB.seek(0);
> // check the UUID
> UUID checkUUID = uuidFactory.recreateUUID(fileLockOnDB.readUTF());
> if (!checkUUID.equals(myUUID))
> {
> throw StandardException.newException(
> SQLState.DATA_MULTIPLE_JBMS_ON_DB, databaseDirectory);
> }
> }
> catch (IOException ioe)
> {
> // probably a read only db, don't do anything more
> readOnly = true;
> try
> {
> if (fileLockOnDB != null)
> fileLockOnDB.close();
> }
> catch (IOException ioe2)
> { /* did the best I could */ }
> fileLockOnDB = null;
> return;
> }
> I think this code can be exercised by creating a database and exiting without
> shutdown. Then change permission on the db.lck and dbex.lck files. It occurs
> often in the field when multiple users with incompatible permissions/umasks
> access the derby database.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira