Error to update to 4.15

nicola2 years ago

Hi,

I tried to update to the latest version from the file "traccar-other-4.15.zipper" but when I try to start the server an exception is thrown:

 Exception in thread "main" java.lang.RuntimeException:                                                                                                                           com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initia                                                                                                                          lize pool: General error: "The write format 1 is smaller than the supported form                                                                                                                          at 2 [2.0.206/5]" [50000-206]
        at org.traccar.Main.run(Main.java:147)
        at org.traccar.Main.main(Main.java:106)
Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed                                                                                                                           to initialize pool: General error: "The write format 1 is smaller than the supp                                                                                                                          orted format 2 [2.0.206/5]" [50000-206]
        at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(Hi                                                                                                                          kariPool.java:596)
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:582)
        at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
        at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
        at org.traccar.database.DataManager.initDatabase(DataManager.java:131)
        at org.traccar.database.DataManager.<init>(DataManager.java:90)
        at org.traccar.Context.init(Context.java:298)
        at org.traccar.Main.run(Main.java:120)
        ... 1 more
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "The write f                                                                                                                          ormat 1 is smaller than the supported format 2 [2.0.206/5]" [50000-206]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:573)
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
        at org.h2.message.DbException.get(DbException.java:216)
        at org.h2.mvstore.db.Store.convertMVStoreException(Store.java:166)
        at org.h2.mvstore.db.Store.<init>(Store.java:140)
        at org.h2.engine.Database.<init>(Database.java:324)
        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.jav                                                                                                                          a:338)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:117)
        at org.h2.Driver.connect(Driver.java:59)
        at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSourc                                                                                                                          e.java:138)
        at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
        at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
        at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470                                                                                                                          )
        at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
        ... 7 more
Caused by: org.h2.mvstore.MVStoreException: The write format 1 is smaller than t                                                                                                                          he supported format 2 [2.0.206/5]
        at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
        at org.h2.mvstore.MVStore.getUnsupportedWriteFormatException(MVStore.jav                                                                                                                          a:1059)
        at org.h2.mvstore.MVStore.readStoreHeader(MVStore.java:878)
        at org.h2.mvstore.MVStore.<init>(MVStore.java:455)
        at org.h2.mvstore.MVStore$Builder.open(MVStore.java:4052)
        at org.h2.mvstore.db.Store.<init>(Store.java:129)
        ... 19 more
catruchos2 years ago

I had the same problem It looks like that former version of h2 traccar used was 1.4.200 and the new one is 2.0.206

and after a lot of try and error I success to install the new version and restore my old h2 database (1.4.200) to the new h2 version (2.0.206) that is the one used by traccar 4.15.

I am not expert at all, and It might be something wrong, but It worked for me.

You need java installed

First of all, before upgrade, you have to make a copy of the old database file, in my case It was in:
/op/traccar/data/database.mv.db

Then I downloaded and extracted the h2-1.4.200.jar file from H2 archive downloads version 1.4.200 platform independent zip
I did the same with the h2-2.0.206.jar file from from H2 archive downloads version 1.4.206 platform independent zip

I put them both on the same folder with the backup copy of the database, in my case in C:\temp
After that I did a database backup from old database following the instructions from This link
The command I use was
java -cp c:\temp\h2-1.4.200.jar org.h2.tools.Script -url jdbc:h2:c:\temp\database -user sa -script test.zip -options compression zip
This creates a zip file named test.zip with a dump of the database

After that I restore the database in 2.0.206 version with this command

java -cp c:\temp\h2-2.0.206.jar org.h2.tools.RunScript -url jdbc:h2:c:\temp\database_new -user sa -script test.zip -options compression zip

After that the database will be created with the name database_new.mv.db.

You have to copy to the database folder on your traccar installation
Stop traccar, delete old version of the file database.mv.db and rename the file database_new_mv.db to database.mv.db

Start traccar, and It should work with all the old data

HJvD2 years ago

Had the same db-problem, and also was puzzled how to convert. Beautiful step-by-step instruction catruchos! Was a bit confused that the test.zip file was not shown in the temp-folder, but that didn't affect the end result. Thank you for writing this down!

nicola2 years ago

Thanks catruchos for the detailed instructions.
I was able to update!

MT2 years ago

catruchos you are a star ! had a nightmare yesterday trying to get traccar to start after the upgrade, your steps worked first time ! thank you : )

Bohdan2 years ago

Thank you!! This should really have been in the release notes so we know to upgrade db prior to upgrade

Jeremie P2 years ago

You can do it directly from unix part too...

# stop traccar
systemctl stop traccar

# create temp directory for fix
mkdir /opt/FIXH2 ; cd /opt/FIXH2

wget https://h2database.com/h2-2019-10-14.zip
wget https://github.com/h2database/h2database/releases/download/version-2.0.206/h2-2022-01-04.zip
unzip h2-2019-10-14.zip
mv h2 ./h2.2019
unzip h2-2022-01-04.zip
mv h2 ./h2.2022

# find ./ -name "*.jar"
./h2.2022/bin/h2-2.0.206.jar
./h2.2022/service/wrapper.jar
./h2.2019/bin/h2-1.4.200.jar
./h2.2019/service/wrapper.jar


# copy old database file (to fix)
root@DID-Traccar:/opt/FIXH2# cp -p /opt/traccar.4.13/data/database.mv.db /opt/FIXH2


# export database with h2.tools (1.4)
root@DID-Traccar:/opt/FIXH2# java -cp ./h2.2019/bin/h2-1.4.200.jar org.h2.tools.Script -url jdbc:h2:./database -user sa -script backup.zip -options compression zip


# export database from backup.zip to (2.0) with h2.tools
root@DID-Traccar:/opt/FIXH2# java -cp ./h2.2022/bin/h2-2.0.206.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 :
root@DID-Traccar:/opt/FIXH2# cp ./database_new.mv.db /opt/traccar/data/database.mv.db

# restart traccar
systemctl start traccar
amibumping2 years ago

@Jeremie P this worked perfect!

Thank you

Just to help for copying:

systemctl stop traccar
mkdir /opt/FIXH2
cd /opt/FIXH2
wget https://h2database.com/h2-2019-10-14.zip
wget https://github.com/h2database/h2database/releases/download/version-2.0.206/h2-2022-01-04.zip
unzip h2-2019-10-14.zip
mv h2 ./h2.2019
unzip h2-2022-01-04.zip
mv h2 ./h2.2022
find ./ -name "*.jar"
cp -p /opt/traccar.4.13/data/database.mv.db /opt/FIXH2
java -cp ./h2.2019/bin/h2-1.4.200.jar org.h2.tools.Script -url jdbc:h2:./database -user sa -script backup.zip -options compression zip
java -cp ./h2.2022/bin/h2-2.0.206.jar org.h2.tools.RunScript -url jdbc:h2:./database_new -user sa -script backup.zip -options compression zip
cp ./database_new.mv.db /opt/traccar/data/database.mv.db
systemctl start traccar
Julian L2 years ago

Thank you for the linux (and windows) walk through, very helpful.

I had an error extracting the data. This is the error:

org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.IllegalStateException: Unable to read the page at position ...

I am upgrading from Traccar 3.4. I have fixed the error above by using an older version of H2 tools (1.4), specifically this version:

https://h2database.com/h2-2019-03-13.zip

The database is then successfully exported.

Avanta year ago

Thanks @amibumping - the summary worked a treat

Mauro Soccia year ago

Same issue from 4.1 to 5.6. Zip file is not visible in the folder but works perfectly and solve the problem. Thanks so much.