SQL Errors in logs after upgrade to 3.12

39 views
Skip to first unread message

Matthias Keller

unread,
Dec 15, 2025, 4:39:26 AM (yesterday) Dec 15
to Repo and Gerrit Discussion
Hi
I've recently tried to update our test instance from 3.10 to 3.12 directly. My steps were:
- Shutdown gerrit
- delete all files in /cache (I did not want to use any migration tool, as simply rebuilding the cache is much easier and can be done in <10mins on our system)
- Upgrade to 3.12.3
- run "init" and let it finish (performing offline update)
- start Gerrit

Afterwards I got various errors in the Logs, probably there's something wrong with the cache migration code?

[2025-11-28T22:33:49.681+01:00] [DiskCache-Prune-1[Disk Cache Pruner (modified_files-v2)]] WARN com.google.gerrit.server.cache.h2.H2CacheImpl : Cannot prune cache jdbc:h2:file:///var/gerrit/cache/modified_files-v2 org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "DATA" already exists; SQL statement: CREATE CACHED TABLE "PUBLIC"."DATA"( "K" JAVA_OBJECT SELECTIVITY 100 NOT NULL, "V" JAVA_OBJECT SELECTIVITY 60 NOT NULL, "CREATED" TIMESTAMP SELECTIVITY 95 NOT NULL, "ACCESSED" TIMESTAMP SELECTIVITY 88 NOT NULL, "SPACE" BIGINT GENERATED ALWAYS AS (OCTET_LENGTH("K") + OCTET_LENGTH("V")) SELECTIVITY 43, "VERSION" INTEGER DEFAULT 0 SELECTIVITY 1 NOT NULL ) [42101-232] at org.h2.message.DbException.getJdbcSQLException(DbException.java:514) at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) at org.h2.message.DbException.get(DbException.java:223) at org.h2.message.DbException.get(DbException.java:199) at org.h2.command.ddl.CreateTable.update(CreateTable.java:91) at org.h2.engine.MetaRecord.prepareAndExecute(MetaRecord.java:77) at org.h2.engine.Database.executeMeta(Database.java:665) at org.h2.engine.Database.executeMeta(Database.java:637) at org.h2.engine.Database.<init>(Database.java:359) 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.google.gerrit.server.cache.h2.H2CacheImpl$SqlHandle.<init>(H2CacheImpl.java:744) at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlStore.acquire(H2CacheImpl.java:716) at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlStore.prune(H2CacheImpl.java:632) at com.google.gerrit.server.cache.h2.H2CacheImpl.prune(H2CacheImpl.java:225) at com.google.gerrit.server.cache.h2.H2CacheFactory$PeriodicCachePruner.run(H2CacheFactory.java:74) at com.google.gerrit.server.logging.LoggingContextAwareRunnable.run(LoggingContextAwareRunnable.java:113) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:912) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583)

Matthias Sohn

unread,
Dec 15, 2025, 4:54:07 AM (yesterday) Dec 15
to Matthias Keller, Repo and Gerrit Discussion
On Mon, Dec 15, 2025 at 10:39 AM 'Matthias Keller' via Repo and Gerrit Discussion <repo-d...@googlegroups.com> wrote:
Hi
I've recently tried to update our test instance from 3.10 to 3.12 directly. My steps were:
- Shutdown gerrit
- delete all files in /cache (I did not want to use any migration tool, as simply rebuilding the cache is much easier and can be done in <10mins on our system)

This isn't necessary since 3.12.x uses different file names for the h2 db files which have a suffix "-v2" in their name.
 
- Upgrade to 3.12.3
- run "init" and let it finish (performing offline update)
- start Gerrit

Afterwards I got various errors in the Logs, probably there's something wrong with the cache migration code?

Gerrit has no migration code to migrate existing persistent H2 caches which were written using H2 v1.x to H2 v2.
Instead Gerrit 3.12.x uses different file names for the h2 db files which have a suffix "-v2" in their name.
This means if you want to use the generic H2 migration tool you have to do that manually when you upgrade
Gerrit to 3.12.x. After the upgrade is finished you can then delete the old cache files which don't have "-v2" in their file name.
Otherwise Gerrit will ignore the old cache files and write new ones for H2 v2.
 

[2025-11-28T22:33:49.681+01:00] [DiskCache-Prune-1[Disk Cache Pruner (modified_files-v2)]] WARN com.google.gerrit.server.cache.h2.H2CacheImpl : Cannot prune cache jdbc:h2:file:///var/gerrit/cache/modified_files-v2 org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "DATA" already exists; SQL statement: CREATE CACHED TABLE "PUBLIC"."DATA"( "K" JAVA_OBJECT SELECTIVITY 100 NOT NULL, "V" JAVA_OBJECT SELECTIVITY 60 NOT NULL, "CREATED" TIMESTAMP SELECTIVITY 95 NOT NULL, "ACCESSED" TIMESTAMP SELECTIVITY 88 NOT NULL, "SPACE" BIGINT GENERATED ALWAYS AS (OCTET_LENGTH("K") + OCTET_LENGTH("V")) SELECTIVITY 43, "VERSION" INTEGER DEFAULT 0 SELECTIVITY 1 NOT NULL ) [42101-232] at org.h2.message.DbException.getJdbcSQLException(DbException.java:514) at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) at org.h2.message.DbException.get(DbException.java:223) at org.h2.message.DbException.get(DbException.java:199) at org.h2.command.ddl.CreateTable.update(CreateTable.java:91) at org.h2.engine.MetaRecord.prepareAndExecute(MetaRecord.java:77) at org.h2.engine.Database.executeMeta(Database.java:665) at org.h2.engine.Database.executeMeta(Database.java:637) at org.h2.engine.Database.<init>(Database.java:359) 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.google.gerrit.server.cache.h2.H2CacheImpl$SqlHandle.<init>(H2CacheImpl.java:744) at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlStore.acquire(H2CacheImpl.java:716) at com.google.gerrit.server.cache.h2.H2CacheImpl$SqlStore.prune(H2CacheImpl.java:632) at com.google.gerrit.server.cache.h2.H2CacheImpl.prune(H2CacheImpl.java:225) at com.google.gerrit.server.cache.h2.H2CacheFactory$PeriodicCachePruner.run(H2CacheFactory.java:74) at com.google.gerrit.server.logging.LoggingContextAwareRunnable.run(LoggingContextAwareRunnable.java:113) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:912) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1583)

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/repo-discuss/4489d0a2-4ea7-42fc-a94a-f15f0e49478an%40googlegroups.com.

Matthias Keller

unread,
Dec 15, 2025, 5:13:02 AM (yesterday) Dec 15
to Repo and Gerrit Discussion
Hi Matthias
Thanks for the insight - but therefore deleting the files upfront is the same as afterwards.
But what really troubles me, are those exceptions showing up afterwards. They show that some code is repeatedly trying to create a table that already exists ("CREATE CACHED TABLE "PUBLIC"."DATA" ...") and the caller is H2CacheImpl.java:744:

Cannot prune cache jdbc:h2:file:///var/gerrit/cache/modified_files-v2
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "DATA" already exists; SQL statement:
CREATE CACHED TABLE "PUBLIC"."DATA"(
    "K" JAVA_OBJECT SELECTIVITY 100 NOT NULL,
    "V" JAVA_OBJECT SELECTIVITY 60 NOT NULL,
    "CREATED" TIMESTAMP SELECTIVITY 95 NOT NULL,
    "ACCESSED" TIMESTAMP SELECTIVITY 88 NOT NULL,
    "SPACE" BIGINT GENERATED ALWAYS AS (OCTET_LENGTH("K") + OCTET_LENGTH("V")) SELECTIVITY 43,
    "VERSION" INTEGER DEFAULT 0 SELECTIVITY 1 NOT NULL

Matthias Sohn

unread,
Dec 15, 2025, 5:22:45 AM (yesterday) Dec 15
to Matthias Keller, Repo and Gerrit Discussion
On Mon, Dec 15, 2025 at 11:13 AM 'Matthias Keller' via Repo and Gerrit Discussion <repo-d...@googlegroups.com> wrote:
Hi Matthias
Thanks for the insight - but therefore deleting the files upfront is the same as afterwards.
But what really troubles me, are those exceptions showing up afterwards. They show that some code is repeatedly trying to create a table that already exists ("CREATE CACHED TABLE "PUBLIC"."DATA" ...") and the caller is H2CacheImpl.java:744:

Cannot prune cache jdbc:h2:file:///var/gerrit/cache/modified_files-v2
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "DATA" already exists; SQL statement:
CREATE CACHED TABLE "PUBLIC"."DATA"(
    "K" JAVA_OBJECT SELECTIVITY 100 NOT NULL,
    "V" JAVA_OBJECT SELECTIVITY 60 NOT NULL,
    "CREATED" TIMESTAMP SELECTIVITY 95 NOT NULL,
    "ACCESSED" TIMESTAMP SELECTIVITY 88 NOT NULL,
    "SPACE" BIGINT GENERATED ALWAYS AS (OCTET_LENGTH("K") + OCTET_LENGTH("V")) SELECTIVITY 43,
    "VERSION" INTEGER DEFAULT 0 SELECTIVITY 1 NOT NULL

Gerrit up to 3.12.x unconditionally and unnecessarily ran the DDL creating the table schema whenever a new DB connection was acquired.
 

Matthias Keller

unread,
Dec 15, 2025, 9:29:18 AM (yesterday) Dec 15
to Repo and Gerrit Discussion
Hi Matthias
Ah many thanks, in this case, you can close the issue 464482034 ... A backport might be very welcome, there are probably more people running into this in the future... But in our case we'll consider moving to 3.13 directly then.
Thanks
Matt
Reply all
Reply to author
Forward
0 new messages