Skip to content

Test for chunk not found - #4382

Draft
kennethjor wants to merge 3 commits into
h2database:masterfrom
kennethjor:chunck-not-found
Draft

kennethjor wants to merge 3 commits into
h2database:masterfrom
kennethjor:chunck-not-found

Conversation

@kennethjor

@kennethjor kennethjor commented Sep 1, 2026

Copy link
Copy Markdown

Test PR to reproduce a chunk not found error:

Exception in thread "main" org.h2.mvstore.MVStoreException: Chunk 6 not found [2.4.240/9]
	at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
	at org.h2.mvstore.FileStore.getChunk(FileStore.java:2015)
	at org.h2.mvstore.FileStore.readPage(FileStore.java:1962)
	at org.h2.mvstore.MVStore.readPage(MVStore.java:1143)
	at org.h2.mvstore.MVMap.readPage(MVMap.java:632)
	at org.h2.mvstore.Page$NonLeaf.getChildPage(Page.java:1158)
	at org.h2.mvstore.Cursor.hasNext(Cursor.java:64)
	at org.h2.mvstore.MVMap$2$1.hasNext(MVMap.java:745)
	at org.h2.test.store.TestMVStoreChunkNotFound.test(TestMVStoreChunkNotFound.java:65)
	at org.h2.test.TestBase.testFromMain(TestBase.java:479)
	at org.h2.test.store.TestMVStoreChunkNotFound.main(TestMVStoreChunkNotFound.java:28)

I have confirmed the test fails off master as well.

I'm not familiar with the codebase enough to actually attempt a fix.

@kennethjor

Copy link
Copy Markdown
Author

@kennethjor

Copy link
Copy Markdown
Author

Failing run off master: https://github.com/kennethjor/h2database/actions/runs/33464900580/job/99722620056#step:4:382

ERROR: FAIL (memory ) org.h2.mvstore.MVStoreException: Chunk 6 not found [2.5.259/9] org.h2.mvstore.MVStoreException: Chunk 6 not found [2.5.259/9] ------------------------------
org.h2.mvstore.MVStoreException: Chunk 6 not found [2.5.259/9]
	at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:998)
	at org.h2.mvstore.FileStore.getChunk(FileStore.java:2024)
	at org.h2.mvstore.FileStore.readPage(FileStore.java:1989)
	at org.h2.mvstore.MVStore.readPage(MVStore.java:1158)
	at org.h2.mvstore.MVMap.readPage(MVMap.java:632)
	at org.h2.mvstore.Page$NonLeaf.getChildPage(Page.java:1203)
	at org.h2.mvstore.Cursor.hasNext(Cursor.java:64)
	at org.h2.mvstore.MVMap$2$1.hasNext(MVMap.java:745)
	at org.h2.test.store.TestMVStoreChunkNotFound.test(TestMVStoreChunkNotFound.java:65)
	at org.h2.test.TestBase.runTest(TestBase.java:147)
	at org.h2.test.TestAll.addTest(TestAll.java:998)
	at org.h2.test.TestAll.testUtils(TestAll.java:920)
	at org.h2.test.TestAll.runTests(TestAll.java:617)
	at org.h2.test.TestAll.testAll(TestAll.java:553)
	at org.h2.test.TestAll.run(TestAll.java:494)
	at org.h2.test.TestAll.main(TestAll.java:438)

@kennethjor

kennethjor commented Sep 1, 2026

Copy link
Copy Markdown
Author

Removed as many custom configurations from the MVStore setup as possible in 5b9f934. The following are required for the test to break. Disabling either of these will make the test pass:

store.setVersionsToKeep(0);
store.setRetentionTime(0);

@kennethjor

kennethjor commented Sep 1, 2026

Copy link
Copy Markdown
Author

cfefa3b removes a bit more from the test. Writing to the store isn't required, just doing repeated commits and compacts is enough to trigger it.

@andreitokar

Copy link
Copy Markdown
Contributor

I think, this case demonstrates the issue with incomplete use of MVStore API, rather than actual problem.
Iterator loop need to be wrapped with this pare of MVStore.de/registerVersionUsage() :

MVStore.TxCounter txCounter = store.registerVersionUsage();
Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
while (it.hasNext()) {
    it.next();
...
    }
}
store.deregisterVersionUsage(txCounter);

Otherwise every version, except the current one, is considered as "not in use" and eligible for collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants