nexus-public icon indicating copy to clipboard operation
nexus-public copied to clipboard

Failed to initialize pool: Database may be already in use

Open Slyke opened this issue 1 year ago • 2 comments

Using sonatype/nexus3:3.77.2

Had a power outage.

I've tried running

rm -f /nexus-data/lock /nexus-data/karaf.pid /nexus-data/db/nexus.lock.db /nexus-data/db/nexus.mv.db.lock

Before starting up Nexus3, but this error persists:

2025-03-03 09:15:21,120+0000 INFO  [FelixStartLevel]  *SYSTEM org.sonatype.nexus.extender.NexusLifecycleManager - Start STORAGE
2025-03-03 09:15:21,143+0000 INFO  [FelixStartLevel]  *SYSTEM com.sonatype.nexus.datastore.DataStoreConfigurationFileSource - Loaded 'nexus' data store configuration from properties file (h2)
2025-03-03 09:15:21,224+0000 INFO  [FelixStartLevel]  *SYSTEM com.zaxxer.hikari.HikariDataSource - nexus - Starting...
2025-03-03 09:15:22,347+0000 ERROR [FelixStartLevel]  *SYSTEM org.sonatype.nexus.datastore.mybatis.MyBatisDataStore - Failed transition: NEW -> STARTED
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Database may be already in use: "/nexus-data/db/nexus.mv.db". Possible solutions: close all other connection(s); use the server mode [90020-232]
	at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:596)
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:582)
	at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
	at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
	at org.sonatype.nexus.datastore.mybatis.MyBatisDataStore.doStart(MyBatisDataStore.java:259)
	at org.sonatype.nexus.datastore.DataStoreSupport.doStart(DataStoreSupport.java:63)
	at org.sonatype.nexus.common.stateguard.StateGuardLifecycleSupport.start(StateGuardLifecycleSupport.java:69)
	at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39)
	at org.sonatype.nexus.common.stateguard.StateGuard$TransitionImpl.run(StateGuard.java:217)
	at org.sonatype.nexus.common.stateguard.TransitionsInterceptor.invoke(TransitionsInterceptor.java:58)
	at org.sonatype.nexus.datastore.internal.DataStoreManagerImpl.doCreate(DataStoreManagerImpl.java:194)
	at org.sonatype.nexus.datastore.internal.DataStoreManagerImpl.tryRestore(DataStoreManagerImpl.java:175)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
	at org.sonatype.nexus.datastore.internal.DataStoreManagerImpl.doStart(DataStoreManagerImpl.java:124)
	at org.sonatype.nexus.common.stateguard.StateGuardLifecycleSupport.start(StateGuardLifecycleSupport.java:69)
	at org.sonatype.nexus.common.stateguard.MethodInvocationAction.run(MethodInvocationAction.java:39)
	at org.sonatype.nexus.common.stateguard.StateGuard$TransitionImpl.run(StateGuard.java:217)
	at org.sonatype.nexus.common.stateguard.TransitionsInterceptor.invoke(TransitionsInterceptor.java:58)
	at org.sonatype.nexus.extender.NexusLifecycleManager.startComponent(NexusLifecycleManager.java:210)
	at org.sonatype.nexus.extender.NexusLifecycleManager.to(NexusLifecycleManager.java:121)
	at org.sonatype.nexus.extender.NexusContextListener.moveToPhase(NexusContextListener.java:332)
	at org.sonatype.nexus.extender.NexusContextListener.frameworkEvent(NexusContextListener.java:229)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1597)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database may be already in use: "/nexus-data/db/nexus.mv.db". Possible solutions: close all other connection(s); use the server mode [90020-232]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:690)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
	at org.h2.message.DbException.get(DbException.java:212)
	at org.h2.mvstore.db.Store.convertMVStoreException(Store.java:165)
	at org.h2.mvstore.db.Store.<init>(Store.java:142)
	at org.h2.engine.Database.<init>(Database.java:326)
	at org.h2.engine.Engine.openSession(Engine.java:92)
	at org.h2.engine.Engine.openSession(Engine.java:222)
	at org.h2.engine.Engine.createSession(Engine.java:201)
	at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:344)
	at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124)
	at org.h2.Driver.connect(Driver.java:59)
	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
	... 23 common frames omitted

It gives this error, even though:

sh-5.1$ ls -ahl /nexus-data/db/
total 23M
drwxrwx--- 1 nexus nexus  50 Mar  3 09:04 .
drwxrwx--- 1 nexus nexus 256 Mar  3 09:14 ..
-rwxrwx--- 1 nexus nexus 23M Jan 25 04:00 nexus.mv.db
-rwxrwx--- 1 nexus nexus 11K Mar  3 09:15 nexus.trace.db

This is using the Docker image.

I should also like to point out that if I just use Docker as is, Nexus3 exits with exitcode 0 and no logs. I have to set the Docker start command to sleep 3600, shell in and run /opt/sonatype/nexus/bin/nexus start to get any logs.

Slyke avatar Mar 03 '25 09:03 Slyke

Should I just blow the database all away and use Postgres?

Slyke avatar Mar 11 '25 09:03 Slyke

same question, i don't how to stop nexus for migration job.

hoanbc avatar Apr 22 '25 10:04 hoanbc