Database version not supported (ASYNC and HOT-FOLDER)
This article describes the origins for the error “The write format 1 is smaller than the supported format 2” and its respective solution hint.
Problem description
Due to a database incompatibility between the older proxy images versions and the new ones, it is required to update the database version when updating the proxy image.
Proxy versions later than v.1.19+b134 are not affected by this issue.
The proxy startup will automatically try to update the database version, and you shouldn’t need to execute any additional steps for doing so.
However, after updating the proxy image and then starting in ASYNC or HOT-FOLDER mode, if there are pending operations to be handled, the proxy may throw a startup exception indicating that the database version is not compatible:
Exception in thread "main" org.h2.jdbc.JdbcSQLNonTransientException: General error: "The write format 1 is smaller than the supported format 2 [2.0.202/5]" [50000-202]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:212)
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:325)
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:342)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:117)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:287)
at org.h2.util.JdbcUtils.getConnection(JdbcUtils.java:270)
at org.h2.tools.RunScript.process(RunScript.java:320)
at org.h2.tools.RunScript.runTool(RunScript.java:144)
at org.h2.tools.RunScript.main(RunScript.java:71)
Caused by: org.h2.mvstore.MVStoreException: The write format 1 is smaller than the supported format 2 [2.0.202/5]
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004)
at org.h2.mvstore.MVStore.getUnsupportedWriteFormatException(MVStore.java: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)
... 11 more
>> Database has an older version (1.4.197). Will validate if exist operations pending execution...
There are operations pending execution with the following external references:
Ext_Ref_710ae8b4-3607-4246-86ed-0800fe96fb30
Ext_Ref_8704dc7f-94fa-4745-83c1-473a7e367c41
Ext_Ref_cd4cc5cc-2ffd-4a08-a856-bce31ee5f715
Ext_Ref_9c8824e5-23f7-4e6f-b70f-69db4725ca68
Ext_Ref_a8b8df05-7250-41e6-9e2b-c2b47aab3555
However, if no pending operations exist, the proxy will automatically update the database version by deleting the current database and recreating a new one with the latest version.
Solution
To solve this error and update the database version, you can follow one of the following approaches.
Approach A (recommended)
Relaunch the older version of the proxy, and wait until all the pending operations are finished. It is important that no further operations are added during this period, in order to clear all the pending input.
After handling all pending operations, you should stop the docker image in use (old proxy version) and start the newly provided docker image (new proxy version).
Since no operations will be pending, the proxy can recreate successfully the database with the new version.
Approach B
You can force the deletion of the current database file (thus potentially losing all the pending operations information) using the parameter force.database.recreate
on the newly provided docker run container.
If a successful database recreation is achieved, you should see a docker image log registry without any errors.
You can then run again without this parameter, to prevent further restarts that will force the database deletion.
Note, you must use the new image version for this step.
Example run command for database deletion:
docker run -d --mount source=vol1,target=/tmp --mount type=bind,source=C:/tmp,target=/home -p 8086:8080 --memory=4g teammust/einvoice:integration-client-ws-eeeb1c66db7fc864d4203c3e857b095f29a7a2e6-87 --server.host.port=127.0.0.1:8086 --einvoice-integration-client.service.domain=https://test.must.digital/ --force.database.recreate=TRUE
It is only necessary to run the docker container with this parameter one single time for database recreation to take effect. For the next subsequent executions, you should remove the parameter.