Repository navigation
Closed
Description
Hello,
In the version 2.4.240, we hit the following exception with a SHUTDOWN COMPACT command:
at <my_class>
at org.codehaus.mojo.exec.ExecJavaMojo.doMain(ExecJavaMojo.java:371)
at org.codehaus.mojo.exec.ExecJavaMojo.doExec(ExecJavaMojo.java:360)
at org.codehaus.mojo.exec.ExecJavaMojo.lambda$execute$0(ExecJavaMojo.java:280)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.util.concurrent.CompletionException: org.h2.mvstore.MVStoreException: java.lang.AssertionError [2.4.240/3]"; SQL statement:
SHUTDOWN COMPACT [50000-240]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:212)
at org.h2.message.DbException.convert(DbException.java:407)
at org.h2.command.Command.executeUpdate(Command.java:318)
at org.h2.command.Command.executeUpdate(Command.java:250)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:262)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:231)
at my.H2DatabaseManager.importH2Statements(H2DatabaseManager.java:379)
... 8 more
Caused by: java.util.concurrent.CompletionException: org.h2.mvstore.MVStoreException: java.lang.AssertionError [2.4.240/3]
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
... 1 more
Caused by: org.h2.mvstore.MVStoreException: java.lang.AssertionError [2.4.240/3]
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
at org.h2.mvstore.FileStore.serializeAndStore(FileStore.java:1446)
at org.h2.mvstore.FileStore.lambda$storeIt$2(FileStore.java:1381)
at org.h2.mvstore.FileStore.submitOrRun(FileStore.java:1406)
at org.h2.mvstore.FileStore.storeIt(FileStore.java:1380)
at org.h2.mvstore.MVStore.storeNow(MVStore.java:965)
at org.h2.mvstore.MVStore.store(MVStore.java:930)
at org.h2.mvstore.MVStore.commit(MVStore.java:900)
at org.h2.mvstore.MVStore.commit(MVStore.java:892)
at org.h2.mvstore.MVStore.registerUnsavedMemoryAndCommitIfNeeded(MVStore.java:1372)
at org.h2.mvstore.MVMap.copy(MVMap.java:1200)
at org.h2.mvstore.MVMap.copyFrom(MVMap.java:1176)
at org.h2.mvstore.MVStore.lambda$compact$0(MVStore.java:435)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
... 3 more
Caused by: java.lang.AssertionError
at org.h2.mvstore.Page$PageReference.clearPageReference(Page.java:1079)
at org.h2.mvstore.Page$NonLeaf.releaseSavedPages(Page.java:1388)
at org.h2.mvstore.FileStore.serializeAndStore(FileStore.java:1441)
... 15 more
Following the PR #4273, we set the system property h2.compactThreads to 1 and the error get away, so this is a simple workaround. If we enforce it to any other value than 1 (tested with 2 and 4), then this error rises.
Note that we are importing an H2 dump from a previous version with RUNSCRIPT and the latter works without any error. Also if we just call SHUTDOWN instead of SHUTDOWN COMPACT, this works also fine, so it seems to be a multithread issue.
Thanks for the work and best regards.
Reacted by neive
Metadata
Metadata
Assignees
Labels
No labels
Activity
naive924 commentedon Sep 25, 2025
Hi, I requested PR #4273 (parallel COMPACT) and I’m happy to help with repro.
On my side (16 cores / latest master branch, daily SHUTDOWN COMPACT, assertions enabled) I can’t reproduce the failure.
Would it be possible to share the RUNSCRIPT-based dataset ? If not, any of the following would still help a lot:
If needed, I can receive it privately. I’ll run it under the same conditions and assist with pinpointing the cause. Thanks!
andreitokar commentedon Sep 27, 2025
I can reproduce it pretty consistently, but it seems that it's just a failing assertion, which just became faulty indeed, because of a parallel execution. Unfortunately in my prior testing i ran this with -da to measure performance.
Assertion need to be removed, and it should be fine otherwise.
naive924 commentedon Sep 27, 2025
Understood.
When I run with the JVM option -ea (-enableassertions) and execute org.h2.tools.Shell, I can also reproduce the issue in my environment. Normally I don’t add -ea, so no AssertionError occurs.
katzyn commentedon Sep 27, 2025
Assertions can be enabled or disabled on individual packages, so you can enable them for your application and disable them for
org.h2package as a temporary workaround.ctabin commentedon Sep 27, 2025
@naive924 Hi, I can confirm we also use
-eaduring our tests causing the assertion failure.naive924 commentedon Sep 29, 2025
@andreitokar
Thank you for your response to #4288.
As I progressed with my investigation, I came to the conclusion that simply removing
assert page.isSaved() || !page.isComplete();is the most reasonable fix.DarkAtra commentedon Aug 29, 2026
@andreitokar, @naive924 i just ran into this exact issue when i tried to fix nitrite/nitrite-java#1284. it seems like the fix from #4288 is not yet released. The last release dates back to Sep 23, 2025. Is there any plan to release a new version of mvstore in the near future that includes this bugfix? Disabling assertions sounds like a short-term workaround, not like something people should have to use for years.
fix(gh-1284): MVStore backend can grow uncontrollably (#1288)