[Deadly] This database is locked by another Cyclos instance

Any issue about installation and configuration of the Cyclos 4 version

Moderators: rmvanarkel, hugo, alexandre

Post Reply
thetopshampound
Posts: 20
Joined: Wed Jun 09, 2021 9:22 am

[Deadly] This database is locked by another Cyclos instance

Post by thetopshampound »

Backing up and restoring cyclos database results in:

Code: Select all

SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
	org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in org.cyclos.bootstrap.BootstrapConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalStateException: This database is locked by another Cyclos instance
	
How to reinstate a database that has moved?
Is it possible to run Cyclos on a mysql database instead of postgres?

DB was backed up as follows:

Code: Select all

root@cyclos-db:/var/lib/postgresql# pg_dump cyclos > cyclos.sql
pg_dump: error: connection to database "cyclos" failed: FATAL:  role "root" does not exist
root@cyclos-db:/var/lib/postgresql# su - cyclos
su: user cyclos does not exist
root@cyclos-db:/var/lib/postgresql# adduser cyclos
Adding user `cyclos' ...
Adding new group `cyclos' (1000) ...
Adding new user `cyclos' (1000) with group `cyclos' ...
Creating home directory `/home/cyclos' ...
Copying files from `/etc/skel' ...

New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for cyclos
Enter the new value, or press ENTER for the default
        Full Name []: cyclos
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] y
root@cyclos-db:/var/lib/postgresql# su - cyclos
cyclos@cyclos-db:~$ ls
cyclos@cyclos-db:~$ pg_dump cyclos > cyclos.sql
cyclos@cyclos-db:~$ ls
cyclos.sql

The db can be restored (in theory) by...

Code: Select all

psql cyclos < cyclos.sql
To retrieve the db from docker to host ...

Code: Select all

# docker cp cyclos-db:/home/cyclos/cyclos.sql .
To post the db to docker from host ...

Code: Select all

# docker cp ./cyclos.sql cyclos-db:/home/cyclos/cyclos.sql
You may want to open up the db for pgadmin ...

Code: Select all

docker cp cyclos-db:/var/lib/postgresql/data/pg_hba.conf .
Add the following line into it and save it back (BUT... do not use this setting in production!)
# all hosts

Code: Select all

host all all 0.0.0.0/32 trust
Push the file back to docker...

Code: Select all

docker cp ./pg_hba.conf cyclos-db:/var/lib/postgresql/data/pg_hba.conf
And reboot postgres container ....

Note: The database will be locked ^^ if the container is respun then restored from the backup (copy protection?).

Postgres 9.6
Tomcat Server version: Apache Tomcat/9.0.46
Cyclos 4.14.10
Last edited by thetopshampound on Wed Jun 23, 2021 4:46 pm, edited 2 times in total.
thetopshampound
Posts: 20
Joined: Wed Jun 09, 2021 9:22 am

Re: [Deadly] This database is locked by another Cyclos instance

Post by thetopshampound »

Trying to swap to an sql datasource...

Code: Select all

### JDBC connection DataSource provider
## C3P0. Any properties under cyclos.datasource.* (except cyclos.datasource.provider)
## is passed as a property to C3P0. For more details, see http://www.mchange.com/projects/c3p0
cyclos.datasource.provider = c3p0
cyclos.datasource.driverClass = org.mysql.Driver
cyclos.datasource.jdbcUrl = jdbc:mysql://127.0.0.1/cyclos
cyclos.datasource.user = cyclos
cyclos.datasource.password = cyclospwd
cyclos.datasource.minPoolSize = 1
cyclos.datasource.maxPoolSize = 20
cyclos.datasource.acquireIncrement = 1
cyclos.datasource.idleConnectionTestPeriod = 60
cyclos.datasource.maxIdleTime = 3600
cyclos.datasource.testConnectionOnCheckout = true
cyclos.datasource.preferredTestQuery = SELECT 1 where pg_is_in_recovery() is false
cyclos.datasource.acquireRetryAttempts = 30
cyclos.datasource.acquireRetryDelay = 1000
cyclos.datasource.numHelperThreads = 5
cyclos.datasource.checkoutTimeout = 300000

Produces error:

Code: Select all

	org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bootstrapConfiguration': Unsatisfied dependency expressed through field 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in URL [jar:file:/opt/tomcatfat/cyclos/WEB-INF/lib/cyclos4-impl-4.14.11.jar!/org/cyclos/bootstrap/DataSourceFactoryBean.class]: Invocation of init method failed; nested exception is java.lang.ClassNotFoundException: org.mysql.Driver
	
Have I misnamed the datasource?
...or am I missing the mysql datasource driver .jar?
dzotic
Posts: 1
Joined: Fri Jul 09, 2021 10:26 am

Re: [Deadly] This database is locked by another Cyclos instance

Post by dzotic »

Hi everyone!

Have the same error in logs:

Code: Select all

java.lang.IllegalStateException: This database is locked by another Cyclos instance
I have a cluster base on balancer node (NGINX), two Cyclos instances (Tomcat9) and two PostgreSQL nodes (master-slave replication)
On cyclos.properties property cyclos.datasource.jdbcUrl connected to master SQL node

So, one of Tomcat server's returns 404.
The issue is reproduced only on 4.14.11. On 4.14.10 everything is OK
Thanks in advance!
Post Reply