Exception Database may be already in use: "Server is running" when using AUTO_SERVER is true

852 views
Skip to first unread message

Brecht Yperman

unread,
Nov 18, 2014, 3:57:34 AM11/18/14
to h2-da...@googlegroups.com
Hi,

I have an application using Hibernate and C3P0 with H2, using the following connection url

jdbc:h2:C:/Program Files (x86)/[...]/data;AUTO_SERVER=true;CACHE_SIZE=262144;MVCC=true

After a while, the user started reporting errors from C3P0 (Could not acquire resource from pool)

When trying to connect from Squirrel SQL, I got the following error:

java.util.concurrent.ExecutionException: java.lang.RuntimeException: org.h2.jdbc.JdbcSQLException: Database may be already in use: "Server is running". Possible solutions: close all other connection(s); use the server mode; SQL statement:
192.168.100.93:59696/149aafb32a4d719e242120aefe36f5993976858617d [90020-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.store.FileLock.checkServer(FileLock.java:244)
at org.h2.store.FileLock.lock(FileLock.java:123)
at org.h2.engine.Database.open(Database.java:557)
at org.h2.engine.Database.openDatabase(Database.java:224)
at org.h2.engine.Database.<init>(Database.java:219)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:160)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:139)
at org.h2.engine.Engine.createSession(Engine.java:122)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:138)
at java.lang.Thread.run(Thread.java:745)

at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(OpenConnectionCommand.java:132)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$100(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$2.run(OpenConnectionCommand.java:115)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: org.h2.jdbc.JdbcSQLException: Database may be already in use: "Server is running". Possible solutions: close all other connection(s); use the server mode; SQL statement:
192.168.100.93:59696/149aafb32a4d719e242120aefe36f5993976858617d [90020-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.store.FileLock.checkServer(FileLock.java:244)
at org.h2.store.FileLock.lock(FileLock.java:123)
at org.h2.engine.Database.open(Database.java:557)
at org.h2.engine.Database.openDatabase(Database.java:224)
at org.h2.engine.Database.<init>(Database.java:219)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:160)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:139)
at org.h2.engine.Engine.createSession(Engine.java:122)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:138)
at java.lang.Thread.run(Thread.java:745)

at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:171)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(OpenConnectionCommand.java:104)
... 5 more
Caused by: org.h2.jdbc.JdbcSQLException: Database may be already in use: "Server is running". Possible solutions: close all other connection(s); use the server mode; SQL statement:
192.168.100.93:59696/149aafb32a4d719e242120aefe36f5993976858617d [90020-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.store.FileLock.checkServer(FileLock.java:244)
at org.h2.store.FileLock.lock(FileLock.java:123)
at org.h2.engine.Database.open(Database.java:557)
at org.h2.engine.Database.openDatabase(Database.java:224)
at org.h2.engine.Database.<init>(Database.java:219)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:160)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:139)
at org.h2.engine.Engine.createSession(Engine.java:122)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:138)
at java.lang.Thread.run(Thread.java:745)

at org.h2.engine.SessionRemote.done(SessionRemote.java:579)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:113)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:403)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:325)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:105)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:90)
at org.h2.Driver.connect(Driver.java:73)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
... 7 more


Any ideas? The auto server seemed to be running at the time, as the port mentioned in the lock file was in use by our software.

Thanks,
Brecht

Noel Grandin

unread,
Nov 19, 2014, 3:11:34 AM11/19/14
to h2-da...@googlegroups.com
Maybe something in your app is leaking connections and your connection pool is becoming exhausted?

Brecht Yperman

unread,
Nov 19, 2014, 4:05:26 AM11/19/14
to h2-da...@googlegroups.com
Would this result in connections from other apps being blocked?

Noel Grandin

unread,
Nov 19, 2014, 4:09:13 AM11/19/14
to h2-da...@googlegroups.com
Should not normally. It's possible the DB is wedged somehow.

Perhaps the next time it happens you could use jstack to take a thread dump of the application?
> --
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> h2-database...@googlegroups.com <mailto:h2-database...@googlegroups.com>.
> To post to this group, send email to h2-da...@googlegroups.com <mailto:h2-da...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/h2-database.
> For more options, visit https://groups.google.com/d/optout.

Brecht Yperman

unread,
Nov 21, 2014, 4:55:43 AM11/21/14
to h2-da...@googlegroups.com
I'll try and do that, thanks.

Brecht


On Wednesday, November 19, 2014 10:09:13 AM UTC+1, Noel Grandin wrote:
Should not normally. It's possible the DB is wedged somehow.

Perhaps the next time it happens you could use jstack to take a thread dump of the application?

On 2014-11-19 11:05 AM, Brecht Yperman wrote:
> Would this result in connections from other apps being blocked?
>
> On Wednesday, November 19, 2014 9:11:34 AM UTC+1, Noel Grandin wrote:
>
>     Maybe something in your app is leaking connections and your connection pool is becoming exhausted?
>
> --
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
Reply all
Reply to author
Forward
0 new messages