Database error after update from 5.8 to 5.9

Rob67ert7 months ago

I get the following error after an update from 5.8 to 5.9:

INFO: Operating system name: Linux version: 5.10.103-v7l+ architecture: arm
2023-11-03 11:44:38  INFO: Java runtime name: OpenJDK Server VM vendor: Eclipse Adoptium version: 17.0.6+10
2023-11-03 11:44:38  INFO: Memory limit heap: 960mb non-heap: 0mb
2023-11-03 11:44:38  INFO: Character encoding: UTF-8 charset: UTF-8
2023-11-03 11:44:38  INFO: Version: 5.9
2023-11-03 11:44:38  INFO: Starting server...
2023-11-03 11:44:38  INFO: HikariPool-1 - Starting...
2023-11-03 11:44:41 ERROR: HikariPool-1 - Exception during pool initialization. - The write format 2 is smaller than the supported format 3 [2.2.220/5] - MVStoreException (... < DatabaseModule:79 < <gener:-1 < *:-1 < ... < MainModule:126 < ...)
2023-11-03 11:44:41 ERROR: Main method error - The write format 2 is smaller than the supported format 3 [2.2.220/5] - MVStoreException (... < DatabaseModule:79 < <gener:-1 < *:-1 < ... < MainModule:126 < ...)

Anyway I can fix it?

gLeW7 months ago

Hi I have the same problem and it’s because use H2 database.
If it’s this you need to migrate to sql or postgre.

I’m not and advance user but it’s what happens to me

Anton Tananaev7 months ago

This has been discussed many times. Please search.

Rob67ert7 months ago

Had to recover my database. Because I did an upgrade before, this did not work; https://www.traccar.org/forums/topic/error-to-update-to-415/
I adjusted is and here the steps I did:

  • stop traccar
    systemctl stop traccar

  • create temp directory for fix
    mkdir /opt/FIXH2 ; cd /opt/FIXH2
    wget https://github.com/h2database/h2database/releases/download/version-2.0.206/h2-2022-01-04.zip
    wget https://github.com/h2database/h2database/releases/download/version-2.2.224/h2-2023-09-17.zip
    unzip h2-2022-01-04.zip
    mv h2 ./h2.2022
    unzip h2-2023-09-17.zip
    mv h2 ./h2.2023

  • find ./ -name "*.jar"
    ./h2.2023/service/wrapper.jar
    ./h2.2023/bin/h2-2.2.224.jar
    ./h2.2022/service/wrapper.jar
    ./h2.2022/bin/h2-2.0.206.jar

  • copy old database file (to fix)
    cp -p /opt/traccar/data/database.mv.db /opt/FIXH2

  • export database with h2.tools
    java -cp ./h2.2022/bin/h2-2.0.206.jar org.h2.tools.Script -url jdbc:h2:./database -user sa -script backup.zip -options compression zip

  • export database from backup.zip
    java -cp ./h2.2023/bin/h2-2.2.224.jar org.h2.tools.RunScript -url jdbc:h2:./database_new -user sa -script backup.zip -options compression zip

  • restore new database file to current traccar data :
    cp ./database_new.mv.db /opt/traccar/data/database.mv.db

  • restart traccar
    systemctl start traccar

AleBu6 months ago

Same problem here, now solved, thank you Rob67ert

David Dunnaway5 months ago

I've done these steps, but still the server won't start

2023-12-08 17:49:25  INFO: Operating system name: Linux version: 3.10.0-1160.102.1.el7.x86_64 architecture: amd64
2023-12-08 17:49:25  INFO: Java runtime name: OpenJDK 64-Bit Server VM vendor: Eclipse Adoptium version: 17.0.6+10
2023-12-08 17:49:25  INFO: Memory limit heap: 948mb non-heap: 0mb
2023-12-08 17:49:25  INFO: Character encoding: UTF-8 charset: UTF-8
2023-12-08 17:49:25  INFO: Version: 5.10
2023-12-08 17:49:25  INFO: Starting server...
2023-12-08 17:49:26  INFO: HikariPool-1 - Starting...
2023-12-08 17:49:27 ERROR: Main method error - The write format 2 is smaller than the supported format 3 [2.2.224/5] - MVStoreException (... < DatabaseModule:79 < <gener:-1 < *:-1 < ... < MainModule:126 < ...)
Anton Tananaev5 months ago

The error indicates that you have not upgraded your database correctly.

David Dunnaway5 months ago

The database is now about 6gb, copying is taking a while. Server now says active / running. But portal is not reachable yet. When i check the command top, i see Java is using about 70% CPU.

David Dunnaway5 months ago
2023-12-08 17:52:37  INFO: Operating system name: Linux version: 3.10.0-1160.102.1.el7.x86_64 architecture: amd64
2023-12-08 17:52:37  INFO: Java runtime name: OpenJDK 64-Bit Server VM vendor: Eclipse Adoptium version: 17.0.6+10
2023-12-08 17:52:37  INFO: Memory limit heap: 948mb non-heap: 0mb
2023-12-08 17:52:37  INFO: Character encoding: UTF-8 charset: UTF-8
2023-12-08 17:52:37  INFO: Version: 5.10
2023-12-08 17:52:37  INFO: Starting server...
2023-12-08 17:52:37  INFO: HikariPool-1 - Starting...
2023-12-08 17:52:39  INFO: HikariPool-1 - Added connection conn0: url=jdbc:h2:./data/database user=SA
2023-12-08 17:52:39  INFO: HikariPool-1 - Start completed.
2023-12-08 17:52:39  INFO: Set default schema name to PUBLIC
2023-12-08 17:52:39  INFO: Clearing database change log checksums
2023-12-08 17:52:40  INFO: Successfully acquired change log lock
2023-12-08 17:52:40  INFO: Successfully released change log lock
2023-12-08 17:52:46  INFO: Reading from PUBLIC.DATABASECHANGELOG
2023-12-08 17:52:46  INFO: Reading from PUBLIC.DATABASECHANGELOG
2023-12-08 17:52:46  INFO: Successfully acquired change log lock
2023-12-08 17:52:46  INFO: Using deploymentId: 2054366994
2023-12-08 17:52:47  INFO: Reading from PUBLIC.DATABASECHANGELOG
2023-12-08 17:52:47  INFO: Columns commandid(INT) added to tc_notifications
2023-12-08 17:52:47  INFO: Foreign key constraint added to tc_notifications (commandid)
2023-12-08 17:52:47  INFO: ChangeSet changelog-5.7::changelog-5.7::author ran successfully in 64ms
2023-12-08 17:52:47  INFO: Column tc_devices.geofenceids dropped
Anton Tananaev5 months ago

Did you run the server before finishing database migration? I'm confused about your comment on copying.

As for the CPU usage, it is expected if there's an ongoing database migration.

David Dunnaway5 months ago

Looks like it hangs it self on one point. Server was off when doing the database migration. Only the copying went wrong, that was why it won't run the first time.

...
2023-12-08 18:17:13  INFO: Waiting for changelog lock....
2023-12-08 18:17:23  INFO: Waiting for changelog lock....
Anton Tananaev5 months ago

The lock usually means that the server got restarted during the migration, leaving the database in potentially corrupted state. You have to manually check the migration, finish any unfinished steps and then remove the lock.

David Dunnaway5 months ago

I redid all the steps, same issue still

2023-12-08 20:15:08 ERROR: Main method error - Could not acquire change log lock.  Currently locked by gps.avlimburg.nl (51.77.64.47) since 12/8/23, 7:42 PM - LockException (... < DatabaseModule:95 < <gener:-1 < *:-1 < ... < MainModule:126 < ...)
2023-12-08 20:15:20  INFO: Operating system name: Linux version: 3.10.0-1160.102.1.el7.x86_64 architecture: amd64
2023-12-08 20:15:20  INFO: Java runtime name: OpenJDK 64-Bit Server VM vendor: Eclipse Adoptium version: 17.0.6+10
2023-12-08 20:15:20  INFO: Memory limit heap: 948mb non-heap: 0mb
2023-12-08 20:15:20  INFO: Character encoding: UTF-8 charset: UTF-8
2023-12-08 20:15:20  INFO: Version: 5.10
2023-12-08 20:15:20  INFO: Starting server...
2023-12-08 20:15:20  INFO: HikariPool-1 - Starting...
2023-12-08 20:15:21  INFO: HikariPool-1 - Added connection conn0: url=jdbc:h2:./data/database user=SA
2023-12-08 20:15:21  INFO: HikariPool-1 - Start completed.
2023-12-08 20:15:21  INFO: Set default schema name to PUBLIC
2023-12-08 20:15:21  INFO: Clearing database change log checksums
2023-12-08 20:15:28  INFO: Waiting for changelog lock....
2023-12-08 20:15:38  INFO: Waiting for changelog lock....
2023-12-08 20:15:48  INFO: Waiting for changelog lock....
2023-12-08 20:15:58  INFO: Waiting for changelog lock....
2023-12-08 20:16:08  INFO: Waiting for changelog lock....