HSQL database opened (in-process) by another application. SQL error when doing: Connecting to HSQLDB

When trying to start TeamCity 6, running on Tomcat6 I receive the following error (from the log):  

[2011-02-16 03:00:20,222]   INFO -   jetbrains.buildServer.SERVER - Database system: HSQL Database Engine 1.8.1

[2011-02-16 03:00:20,222]   INFO -   jetbrains.buildServer.SERVER - Database driver: HSQL Database Engine Driver 1.8.1

[2011-02-16 03:00:20,222]   INFO -   jetbrains.buildServer.SERVER - Database format version: 0

[2011-02-16 03:00:28,957] ERROR -  jetbrains.buildServer.CLEANUP - Unexpected error occured during cleanup

jetbrains.buildServer.serverSide.db.UnexpectedDBException: Unexpected exception when trying to connect from TeamCityDataSource: Cannot create PoolableConnectionFactory (The database is already in use by another process: lockFile: org.hsqldb.persist.LockFile@d72e01aa[file =D:\BuildServer\system\buildserver.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2011-02-16 03:00:27.910 heartbeat - read: -5141 ms.)

SQL exception: Cannot create PoolableConnectionFactory (The database is already in use by another process: lockFile: org.hsqldb.persist.LockFile@d72e01aa[file =D:\BuildServer\system\buildserver.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2011-02-16 03:00:27.910 heartbeat - read: -5141 ms.)

 at jetbrains.buildServer.serverSide.db.TeamCityDataSource.connect(TeamCityDataSource.java:81)

 at jetbrains.buildServer.serverSide.db.DBFacade.createPoolingDataSource(DBFacade.java:124)

 at jetbrains.buildServer.serverSide.db.DBFacade.compact(DBFacade.java:227)

 at jetbrains.buildServer.serverSide.impl.cleanup.ServerCleanupManagerImpl.startCleanup(ServerCleanupManagerImpl.java:4)

 at jetbrains.buildServer.serverSide.impl.cleanup.ServerCleanupManagerImpl$2.run(ServerCleanupManagerImpl.java:3)

 at java.util.TimerThread.mainLoop(Timer.java:512)

 at java.util.TimerThread.run(Timer.java:462)

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The database is already in use by another process: lockFile: org.hsqldb.persist.LockFile@d72e01aa[file =D:\BuildServer\system\buildserver.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2011-02-16 03:00:27.910 heartbeat - read: -5141 ms.)

 at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)

 at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)

 at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)

 at jetbrains.buildServer.serverSide.db.TeamCityDataSource.connect(TeamCityDataSource.java:77)

 ... 6 more

Caused by: java.sql.SQLException: The database is already in use by another process: lockFile: org.hsqldb.persist.LockFile@d72e01aa[file =D:\BuildServer\system\buildserver.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2011-02-16 03:00:27.910 heartbeat - read: -5141 ms.

 at org.hsqldb.jdbc.Util.sqlException(Util.java:63)

 at org.hsqldb.jdbc.jdbcConnection.<init>(jdbcConnection.java:2430)

 at org.hsqldb.jdbcDriver.getConnection(jdbcDriver.java:183)

 at org.hsqldb.jdbcDriver.connect(jdbcDriver.java:161)



Ok, I've seen this before and have been able to resolve it by 1) stopping Tomcat, 2) killing all java.exe processes, 3) deleting the DB .lck file, 4) restarting.
This time that does not work, same issue.  I've rebooted the machine as well.

Is there more I can do to debug the issue?  Any other ideas out there?

Thanks in advance for your help.

jason
1 comment
Comment actions Permalink

We resolved the issue by email, but if anyone meet similar problems - root cause in this particular case was a database corruption.
HSQLDB may log weird messages about locked files, even if no parallel processes actually exist. It's a common error if the driver cannot access a database - due to permissions, or broken file structure.

We recommend to use HSQLDB for evaluation purposes only, and have a fresh backup always.

Michael

0

Please sign in to leave a comment.