InternalError thrown from MmapSegmentRecoveryFaultTest.testScanFaultOnMapPastEofIsHandledAnyFilesystem()
还没有人认领这个 Issue。
评估
- 难度
- 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 小时
- 30 天内合并 PR
- 3
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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
-
难度 1/5 1 小时以内 新手友好度 92/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 72/100
oracle/javavscode#652 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
OpenAPITools/openapi-generator#25014 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
AloisSeckar/demos-java#380 ·