db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dag.wan...@oracle.com (Dag H. Wanvik)
Subject Re: Disappearing service.properties file
Date Mon, 30 May 2011 16:43:22 GMT

Hi Brett,

some possibilities below.

"Brett Mason" <b.mason@adinstruments.com> writes:

> We've recently had some of customer reports come in where Derby is failing
> with problems related to "service.properties". There are three different
> cases but all appear to be similar:
>
> Case 1:
> "ERROR XBM0S: Unable to rename file 'C:\PATH_TO_DB\service.properties' to
> 'C:\PATH_TO_DB\service.propertiesold' " is thrown when trying to call
> SYSCS_DISABLE_LOG_ARCHIVE_MODE(1). Both "service.properties" and
> "service.propertiesold" are present in the database directory. Removing
> "service.propertiesold" corrects the problem.

The relevant code is in
StorgaeFactoryService#saveServiceProperties(String, StorageFactory,
Properties, boolean replace) called with  replace == true.

I think we have seen in some cases on Windows that file handles are open
longer than expected. In any case, the rename fails here, and the reason
for this is intrinsically platform specific, cf. the Java API
Properties, boolean)File#renameTo.

>
> Case 2:
> "SQLException: Database 'C:\PATH_TO_DB' not found" is thrown when booting
> the database. The file service.properties does not exist in the database
> directory but service.propertiesold does exist. Renaming the file back to
> "service.properties" corrects the problem.

In this case, the rename has been performed ("old" backup exists), but
Derby hasn't been able to write the new version of the properties file.
If Derby tried but failed to write the new version, one should see the
exception XBM01 (cf. throw Monitor.exceptionStartingModule(ioe) in the
code).

"Startup failed due to an exception. See next exception for details"

on derby.log.

One could see the described scenario if Derby (or the system) was
forcibly stopped at this point: the next boot would then not find
"derby.properties".

>
> Case 3: 
> Same as Case 2, except both "service.properties" and "service.propertiesold"
> are missing. We will probably use a backup to restore service.properties in
> this case.

Looking at the code, it seems the only way this can happen is if Derby
thinks the writing of the new "derby.properties" file went ok. The code
performs an explicit "sync" call to make sure the change is persisted to
disk before it goes on the delete the backup file. One could, perhaps,
see this if the file system or driver didnt really honor the write sync
call, but the delete somehow got persisted, followed by a system
crash(?).

Thanks,
Dag


>
>
> In all cases there are no errors logged from the database prior to the
> problems above. I suspect derby has been terminated or interrupted while
> updating the service.properties file and left the file system in an
> inconsistent state. Although I imagine the window for this to happen would
> be fairly narrow.
>
> As far as I can tell the call to SYSCS_DISABLE_LOG_ARCHIVE_MODE(1), which is
> called during our nightly maintenance task, is the only place in our
> application which updates service.properties. Fortunately this call is no
> longer needed so we have removed it.
>
>
> Does this assessment sound reasonable? Are there any other steps we should
> be taking to avoid this problem?
>
> I've included details of the customer environments and full exception
> details below.
>
> Thanks,
> Brett.
>
>
> The details:
>
> Environment:
> - Derby 10.6.1.0
> - Sun JavaSE 1.6 update 20 32-bit.
> - Windows XP/7
>
> Exception 1:
> Caused by: java.sql.SQLException: The exception
> 'org.apache.derby.iapi.error.PassThroughException: ERROR XBM0S: Unable to
> rename file 'C:\PATH_TO_DB\service.properties' to
> 'C:\PATH_TO_DB\service.propertiesold'' was thrown while evaluating an
> expression.
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
> 	at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknow
> n Source)
> 	at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown
> Source)
> 	at
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
> 	at
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
> 	at
> org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
> 	at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown
> Source)
> 	... 43 more
> Caused by: java.sql.SQLException: The exception
> 'org.apache.derby.iapi.error.PassThroughException: ERROR XBM0S: Unable to
> rename file 'C:\PATH_TO_DB\service.properties' to
> 'C:\PATH_TO_DB\service.propertiesold'' was thrown while evaluating an
> expression.
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
> Source)
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossD
> RDA(Unknown Source)
> 	... 53 more
> Caused by: java.sql.SQLException: Java exception: 'ERROR XBM0S: Unable to
> rename file 'C:\PATH_TO_DB\service.properties' to
> 'C:\PATH_TO_DB\service.propertiesold':
> org.apache.derby.iapi.error.PassThroughException'.
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
> Source)
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossD
> RDA(Unknown Source)
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
> 	at
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknow
> n Source)
> 	... 50 more
> Caused by: org.apache.derby.iapi.error.PassThroughException: ERROR XBM0S:
> Unable to rename file 'C:\PATH_TO_DB\service.properties' to
> 'C:\PATH_TO_DB\service.propertiesold'
> 	at
> org.apache.derby.impl.services.monitor.UpdateServiceProperties.update(Unknow
> n Source)
> 	at
> org.apache.derby.impl.services.monitor.UpdateServiceProperties.put(Unknown
> Source)
> 	at
> org.apache.derby.impl.store.access.PropertyConglomerate.saveServiceProperty(
> Unknown Source)
> 	at
> org.apache.derby.impl.store.access.PropertyConglomerate.saveProperty(Unknown
> Source)
> 	at
> org.apache.derby.impl.store.access.PropertyConglomerate.setProperty(Unknown
> Source)
> 	at
> org.apache.derby.impl.store.access.RAMTransaction.setProperty(Unknown
> Source)
> 	at
> org.apache.derby.impl.store.raw.log.LogToFile.disableLogArchiveMode(Unknown
> Source)
> 	at
> org.apache.derby.impl.store.raw.RawStore.disableLogArchiveMode(Unknown
> Source)
> 	at
> org.apache.derby.impl.store.access.RAMAccessManager.disableLogArchiveMode(Un
> known Source)
> 	at
> org.apache.derby.impl.db.BasicDatabase.disableLogArchiveMode(Unknown Source)
> 	at
> org.apache.derby.catalog.SystemProcedures.SYSCS_DISABLE_LOG_ARCHIVE_MODE(Unk
> nown Source)
> 	at
> org.apache.derby.exe.acf477c2e6x012dxb876xe76exffffcae058941.g0(Unknown
> Source)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 	at java.lang.reflect.Method.invoke(Unknown Source)
> 	at
> org.apache.derby.impl.services.reflect.ReflectMethod.invoke(Unknown Source)
> 	at
> org.apache.derby.impl.sql.execute.CallStatementResultSet.open(Unknown
> Source)
> 	at
> org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown
> Source)
> 	at
> org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
> 	... 46 more
> Caused by: ERROR XBM0S: Unable to rename file
> 'C:\PATH_TO_DB\service.properties' to 'C:\PATH_TO_DB\service.propertiesold'
> 	at
> org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
> 	at
> org.apache.derby.impl.services.monitor.StorageFactoryService$5.run(Unknown
> Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at
> org.apache.derby.impl.services.monitor.StorageFactoryService.saveServiceProp
> erties(Unknown Source)
> 	... 66 more
>
>
> Exception 2:
> Caused by: java.sql.SQLException: Database 'C:\PATH_TO_DB' not found.
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
> Source)
> 	at
> org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
> 	at
> org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown
> Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown
> Source)
> 	at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown
> Source)
> 	at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
> 	at org.apache.derby.jdbc.EmbeddedDataSource.getConnection(Unknown
> Source)
> 	at org.apache.derby.jdbc.EmbeddedDataSource.getConnection(Unknown
> Source)
> 	at
> com.ADInstruments.LTS.dataAccess.ConnectionFactory.openConnection(Unknown
> Source)
> 	... 10 more
> Caused by: java.sql.SQLException: Database 'C:\PATH_TO_DB' not found.
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
> Source)
> 	at
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossD
> RDA(Unknown Source)
> 	... 24 more
>
>
>
>

-- 

Mime
View raw message