Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

InternalError thrown from MmapSegmentRecoveryFaultTest.testScanFaultOnMapPastEofIsHandledAnyFilesystem()

Aperta
#69 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
java

Direzione di ricerca

Inizia da MmapSegment.openExisting in MmapSegment.java e dai metodi che falliscono testScanFaultOnMapPastEofIsHandledAnyFilesystem e testHeaderFaultOnMapPastEofIsSkippableAnyFilesystem di MmapSegmentRecoveryFaultTest. Esegui questi test in un ambiente JDK 8, quindi verifica che l'errore map-past-EOF venga gestito in modo affidabile nelle condizioni di compilazione di CI e che la suite di test abbia esito positivo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
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:

  1. 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.
  2. 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

Lingua principale
Java
Stelle
10
Fork
6
Merge medio
8g 1h
PR unite (30g)
3

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di questdb/java-questdb-client

Tutte le issue di questdb/java-questdb-client

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.