You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Michael Closson <cl...@gmail.com> on 2010/06/09 18:38:48 UTC
After an abnormal shutdown, cannot connect to derby DB.
Hello All,
My company uses embedded derby DB for persistence (w/ hibernate) in one of
our server products. We have been using it for several years now.
We are using derby version 10.3. (Bundle-Version: 10.3.1000004.561794)
Recently at a customer site, the server couldn't start because it could not
connect to the database. It happened after the server shutdown abnormally.
The error message reported in the log file is:
Caused by: java.sql.SQLException: Failed to start database 'db', see the
next exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.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.jdbc.Driver30.getNewEmbedConnection(Unknown
Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at
com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:65)
at
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:66)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.initializeAutomaticTestTable(C3P0PooledConnectionPoolManager.java:472)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.createPooledConnectionPool(C3P0PooledConnectionPoolManager.java:406)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool(C3P0PooledConnectionPoolManager.java:327)
at
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool(C3P0PooledConnectionPoolManager.java:345)
at
com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:64)
at
org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:298)
at
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:110)
at
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:88)
at
org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
at org.hibernate.loader.Loader.doQuery(Loader.java:390)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
... 11 more
Caused by: java.sql.SQLException: Java exception: ':
java.lang.IndexOutOfBoundsException'.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
... 37 more
Indeed, if I try to connect to the database with IJ, I get the same error.
If I connect with jars that I built from derby source (10.6, latest) I get a
different error:
[mclosson@magrath work]$ java org.apache.derby.tools.ij
ij version 10.6
ij> connect 'jdbc:derby:db';
org.apache.derby.shared.common.sanity.AssertFailure: ASSERT FAILED Wrong
LogInstant on log record (1392542017,37698) version real position
(392,719194)
at
org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:162)
at
org.apache.derby.shared.common.sanity.SanityManager.THROWASSERT(SanityManager.java:147)
at
org.apache.derby.impl.store.raw.log.Scan.getNextRecordForward(Scan.java:810)
at org.apache.derby.impl.store.raw.log.Scan.getNextRecord(Scan.java:206)
at
org.apache.derby.impl.store.raw.log.FileLogger.readLogRecord(FileLogger.java:1612)
at
org.apache.derby.impl.store.raw.log.LogToFile.findCheckpoint(LogToFile.java:2806)
at org.apache.derby.impl.store.raw.log.LogToFile.recover(LogToFile.java:756)
at org.apache.derby.impl.store.raw.RawStore.boot(RawStore.java:339)
...
Perhaps derby wrote an incomplete log record, and now cannot recover? Also,
if I delete the log control file (log.ctrl) then I can connect OK. But if I
do this, is there risk that some transactions will be lost? (I think so).
Anyways, I looked for existing bugs similar to this one and the closest
thing I can find is DERBY-3896 (
https://issues.apache.org/jira/browse/DERBY-3896), which is still open.
Shall I log this as a new bug?
Lastly, I have the database that causes this error, but I prefer to not post
it to the bug log or mailing list. But if someone emails me directly, I
will supply it.
Thanks!
Mike Closson
Re: After an abnormal shutdown, cannot connect to derby DB.
Posted by Michael Closson <cl...@gmail.com>.
Thanks Knut!
Logged as https://issues.apache.org/jira/browse/DERBY-4697
<https://issues.apache.org/jira/browse/DERBY-4697>Mike C
On Wed, Jun 9, 2010 at 6:15 PM, Knut Anders Hatlen <Kn...@sun.com>wrote:
> On 06/ 9/10 06:38 PM, Michael Closson wrote:
> > Perhaps derby wrote an incomplete log record, and now cannot recover?
> > Also, if I delete the log control file (log.ctrl) then I can connect
> > OK. But if I do this, is there risk that some transactions will be
> > lost? (I think so).
>
> Yes, and there's also a risk that parts of transactions are lost and
> that uncommitted updates are persisted. It might work as a last resort
> to recover data from the database, but the integrity of the data cannot
> be guaranteed. If the log is corrupt, recovery from the last good backup
> is the only safe way to get the database back into a consistent state.
>
> > Anyways, I looked for existing bugs similar to this one and the
> > closest thing I can find is DERBY-3896
> > (https://issues.apache.org/jira/browse/DERBY-3896), which is still open.
> >
> > Shall I log this as a new bug?
>
> DERBY-3896 is a problem that only affects replication, so I think that's
> a different bug, even if the same assert is triggered. A new bug report
> would be best.
>
> > Lastly, I have the database that causes this error, but I prefer to
> > not post it to the bug log or mailing list. But if someone emails me
> > directly, I will supply it.
>
> Just attaching what you have of logs and stack traces first is fine. But
> please keep a copy of the database in case someone needs more info when
> they start investigating the issue.
>
> --
> Knut Anders
>
>
Re: After an abnormal shutdown, cannot connect to derby DB.
Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
On 06/ 9/10 06:38 PM, Michael Closson wrote:
> Perhaps derby wrote an incomplete log record, and now cannot recover?
> Also, if I delete the log control file (log.ctrl) then I can connect
> OK. But if I do this, is there risk that some transactions will be
> lost? (I think so).
Yes, and there's also a risk that parts of transactions are lost and
that uncommitted updates are persisted. It might work as a last resort
to recover data from the database, but the integrity of the data cannot
be guaranteed. If the log is corrupt, recovery from the last good backup
is the only safe way to get the database back into a consistent state.
> Anyways, I looked for existing bugs similar to this one and the
> closest thing I can find is DERBY-3896
> (https://issues.apache.org/jira/browse/DERBY-3896), which is still open.
>
> Shall I log this as a new bug?
DERBY-3896 is a problem that only affects replication, so I think that's
a different bug, even if the same assert is triggered. A new bug report
would be best.
> Lastly, I have the database that causes this error, but I prefer to
> not post it to the bug log or mailing list. But if someone emails me
> directly, I will supply it.
Just attaching what you have of logs and stack traces first is fine. But
please keep a copy of the database in case someone needs more info when
they start investigating the issue.
--
Knut Anders