Hi, all.  I am using Derby embedded in a server process.  The server process can receive a request to shut down, in which case it does an orderly shutdown of all its services.  This uses ExecutorService.shutdownNow(), which sends an InterruptException to any task currently running.  I am looking at changing this to using shutdown with a timeout before reverting to shutdownNow(), but I still want to discuss with you what happens.

It *appears* that as a result of receiving this interrupt, Derby receives a java.nio.channels.ClosedByInterruptException, which it then rethrows as a SQLException.  That's fine, I can dig through the layers of causes to find that it's a ClosedByInterruptException.  But my question to you is, when Derby gets interrupted like this, what does it do?  Does it correctly roll back the current transaction?  Does it ignore the interrupt until it can finish processing the transaction?  I am particularly concerned that this could cause some kind of inconsistency or corruption in the database.

For your edification, here is the stack trace.  I am not sure if it always happens when trying to open a connection, or if it also happens in the middle of an operation, I'm going to look for more examples of the stack trace, and will send it your way.

Thanks!

David
com.vontu.itemcatalog.api.ItemCatalogException: java.sql.SQLException: Failed to start database 'C:\Vontu\Protect\scan\incremental_index/MONITOR_TARGET_4', see the next exception for details.
at com.vontu.itemcatalog.derby.DBCPConnectionPool.getConnection(DBCPConnectionPool.java:71)
at com.vontu.itemcatalog.derby.SQLCallable.call(SQLCallable.java:53)
at com.vontu.itemcatalog.derby.SQLCallable.call(SQLCallable.java:44)
at com.vontu.itemcatalog.derby.PendingDeliveriesPersister.createTablesAsNeeded(PendingDeliveriesPersister.java:47)
at com.vontu.itemcatalog.derby.PendingDeliveriesPersister.<init>(PendingDeliveriesPersister.java:42)
at com.vontu.itemcatalog.derby.PendingDeliveriesPersister.<init>(PendingDeliveriesPersister.java:29)
at com.vontu.itemcatalog.derby.PendingDeliveriesPersisterProvider.getPersister(PendingDeliveriesPersisterProvider.java:25)
at com.vontu.itemcatalog.marshall.BloomFilterBatchMarshallableProvider.getNextMarshallable(BloomFilterBatchMarshallableProvider.java:89)
at com.vontu.itemcatalog.distribution.ItemSetSender.execute(ItemSetSender.java:121)
at com.vontu.itemcatalog.distribution.ItemSetSender.run(ItemSetSender.java:104)
at com.vontu.discover.incremental.ItemSetSenderDispatcher.run(ItemSetSenderDispatcher.java:83)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Failed to start database 'C:\Vontu\Protect\scan\incremental_index/MONITOR_TARGET_4', see the next exception for details.
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.EmbedConnection.bootDatabase(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.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:48)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:840)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:95)
at com.vontu.itemcatalog.derby.DBCPConnectionPool.getConnection(DBCPConnectionPool.java:66)
... 19 more
Caused by: java.sql.SQLException: Failed to start database 'C:\Vontu\Protect\scan\incremental_index/MONITOR_TARGET_4', see the next exception for details.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 36 more
Caused by: java.sql.SQLException: Java exception: ': java.nio.channels.ClosedByInterruptException'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(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)
... 33 more
Caused by: java.nio.channels.ClosedByInterruptException
at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:184)
at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:627)
at org.apache.derby.impl.store.raw.data.RAFContainer4.readFull(Unknown Source)
at org.apache.derby.impl.store.raw.data.RAFContainer4.getEmbryonicPage(Unknown Source)
at org.apache.derby.impl.store.raw.data.RAFContainer.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.derby.impl.store.raw.data.RAFContainer.openContainer(Unknown Source)
at org.apache.derby.impl.store.raw.data.RAFContainer4.openContainer(Unknown Source)
at org.apache.derby.impl.store.raw.data.FileContainer.setIdent(Unknown Source)
at org.apache.derby.impl.store.raw.data.RAFContainer.setIdentity(Unknown Source)
at org.apache.derby.impl.services.cache.ConcurrentCache.find(Unknown Source)
at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.openContainer(Unknown Source)
at org.apache.derby.impl.store.raw.data.BaseDataFileFactory.openContainer(Unknown Source)
at org.apache.derby.impl.store.raw.xact.Xact.openContainer(Unknown Source)
at org.apache.derby.impl.store.access.heap.HeapConglomerateFactory.readConglomerate(Unknown Source)
at org.apache.derby.impl.store.access.RAMAccessManager.conglomCacheFind(Unknown Source)
at org.apache.derby.impl.store.access.RAMTransaction.findExistingConglomerate(Unknown Source)
at org.apache.derby.impl.store.access.RAMTransaction.openScan(Unknown Source)
at org.apache.derby.impl.store.access.PropertyConglomerate.openScan(Unknown Source)
at org.apache.derby.impl.store.access.PropertyConglomerate.readDbProperties(Unknown Source)
at org.apache.derby.impl.store.access.PropertyConglomerate.getCachedDbProperties(Unknown Source)
at org.apache.derby.impl.store.access.PropertyConglomerate.getCachedProperty(Unknown Source)
at org.apache.derby.impl.store.access.PropertyConglomerate.getProperty(Unknown Source)
at org.apache.derby.impl.store.access.PC_XenaVersion.upgradeIfNeeded(Unknown Source)
at org.apache.derby.impl.store.access.PropertyConglomerate.<init>(Unknown Source)
at org.apache.derby.impl.store.access.RAMAccessManager.boot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source)
at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source)
at org.apache.derby.impl.db.BasicDatabase.bootStore(Unknown Source)
at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source)
at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.startProviderService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown Source)
at org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown Source)
at org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown Source)
... 33 more


--
David W. Van Couvering

http://www.linkedin.com/in/davidvc
http://davidvancouvering.blogspot.com
http://twitter.com/dcouvering