InternalError thrown from MmapSegmentRecoveryFaultTest.testScanFaultOnMapPastEofIsHandledAnyFilesystem()
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- java
- 領域
- backend, testing-qa
調査の方向性
MmapSegment.java の MmapSegment.openExisting と、MmapSegmentRecoveryFaultTest の失敗しているメソッド testScanFaultOnMapPastEofIsHandledAnyFilesystem および testHeaderFaultOnMapPastEofIsSkippableAnyFilesystem から着手します。これらのテストを JDK 8 環境で実行し、その後、CI のコンパイル条件下で map-past-EOF のフォールトが確実に処理され、テストスイートが成功することを確認します。
索引モデルが issue の本文から書いたものです。
説明
To reproduce
What failed: one test on the JDK 8 job — MmapSegmentRecoveryFaultTest.testHeaderFaultOnMapPastEofIsSkippableAnyFilesystem — with java.lang.InternalError: a fault occurred in
a recent unsafe memory access operation in compiled Java code (1 error out of 2792 → BUILD FAILURE).
This is QWP store-and-forward mmap-recovery code, from commit 5cc68a9 (fix(qwp): recover an SF slot whose segment tail is an unbacked mapped page (#64)).
Root cause (the interesting part): MmapSegment.openExisting reads the header magic via Unsafe.getInt on a page mapped beyond EOF,
wrapped in catch (Throwable t) → isMmapAccessFault(t) → convert to MmapSegmentException (line 328/345).
But the CI stack trace shows the InternalError at the test's line 292 with no openExisting frame — under the JDK 8 C2 JIT, openExisting gets inlined and
the "recent unsafe access" fault is thrown asynchronously at the inlined call site, bypassing the inlined catch (so isMmapAccessFault never even runs).
The author knew this territory is fragile — scanFrames has its own catch (InternalError) with a long comment about pre-21-JDK fault catchability, and the sibling
test explicitly tolerates the "C2: fault escaped to openExisting's outer catch" case. The difference: the branch runs a much larger suite (all the OIDC feature tests, already there before my review), which warms the JIT enough to C2-compile openExisting by the time this test runs; main's smaller suite leaves it interpreted/C1, where the catch holds.
Recommendation
This is a pre-existing flake in #64's QWP recovery code, surfaced by the branch's larger test suite — not something to fix in the OIDC review PR, and I won't blind-patch delicate JDK-8 Unsafe-fault code I can't reproduce locally (I'm on JDK 17/macOS). The fix belongs in #64's code and needs a JDK 8 environment to verify. Options for whoever owns it:
- Make the header-fault conversion C2-robust — keep the faulting Unsafe.getInt header read in a non-inlinable frame (a @DontInline/CompilerControl barrier, or a small helper scanFrames-style with its own tight catch (InternalError)) so the async fault can't escape an inlined catch.
- Route the recovery test through SegmentRing (the real recovery path) rather than calling MmapSegment.openExisting directly, matching how production actually skips a bad .sfa.
Log:
[INFO] Running io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest
14:09:53.723 [main] WARN io.questdb.client.cutlass.qwp.client.sf.cursor.MmapSegment -- SF segment /tmp/qdb-mmap-recover-168048958392/seg-unbacked-payload.sfa: torn tail of 1040400 bytes at offset 8176 (file size 1048576, frames recovered 1). Recovery will overwrite this region on next append; frames past the tear (if any) are discarded. Investigate disk health or unexpected writer crash.
14:09:53.724 [main] WARN io.questdb.client.cutlass.qwp.client.sf.cursor.MmapSegment -- SF segment /tmp/qdb-mmap-recover-168050228340/seg-mappasteof-scan.sfa: torn tail of 4096 bytes at offset 4096 (file size 8192, frames recovered 1). Recovery will overwrite this region on next append; frames past the tear (if any) are discarded. Investigate disk health or unexpected writer crash.
Error: Tests run: 5, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.008 s <<< FAILURE! -- in io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest
Error: io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest.testScanFaultOnMapPastEofIsHandledAnyFilesystem -- Time elapsed: 0.004 s <<< ERROR!
java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code
at io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest.lambda$testScanFaultOnMapPastEofIsHandledAnyFilesystem$3(MmapSegmentRecoveryFaultTest.java:257)
at io.questdb.client.test.tools.TestUtils.assertMemoryLeak(TestUtils.java:129)
at io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest.testScanFaultOnMapPastEofIsHandledAnyFilesystem(MmapSegmentRecoveryFaultTest.java:242)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
Error: io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest.testHeaderFaultOnMapPastEofIsSkippableAnyFilesystem -- Time elapsed: 0.001 s <<< ERROR!
java.lang.InternalError: a fault occurred in a recent unsafe memory access operation in compiled Java code
at io.questdb.client.cutlass.qwp.client.sf.cursor.MmapSegment.openExisting(MmapSegment.java:332)
at io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest.lambda$testHeaderFaultOnMapPastEofIsSkippableAnyFilesystem$4(MmapSegmentRecoveryFaultTest.java:292)
at io.questdb.client.test.tools.TestUtils.assertMemoryLeak(TestUtils.java:129)
at io.questdb.client.test.cutlass.qwp.client.sf.cursor.MmapSegmentRecoveryFaultTest.testHeaderFaultOnMapPastEofIsSkippableAnyFilesystem(MmapSegmentRecoveryFaultTest.java:283)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:316)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
QuestDB version:
latest
OS, in case of Docker specify Docker and the Host OS:
JDK 8 CI pipeline
File System, in case of Docker specify Host File System:
JDK 8 CI pipeline
Full Name:
glasstiger
Affiliation:
QuestDB
Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?
- Yes, I have
Additional context
No response
- 主要言語
- Java
- スター
- 10
- フォーク
- 6
- 平均マージ
- 8日 1時間
- マージ済み PR(30日)
- 3
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
questdb/java-questdb-client のほかの issue
-
bug QWP
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
questdb/java-questdb-client#100 ·
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
questdb/java-questdb-client#18 · コメント 1 件 ·
questdb/java-questdb-client の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
checkstyle/checkstyle#21755 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
github/copilot-sdk#2782 ·
メンテナーはふだん 1 日以内に返信
-
documentation Good for newcomer quick win
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
CodeForPhilly/benefit-decision-toolkit#519 ·
メンテナーはふだん 1 日以内に返信
-
area-deployment triage:bot-seen triage:needs-human
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/aspire#20533 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信