Commit 0a345a1
fix(qwp): read the SF recovery scan via pread instead of the mapping
Recovery-time reads of a segment file go through pread into a private
buffer: the header block, the frame scan, the CRC fold, and the
torn-tail probe. Unreadable regions are then ordinary read results
with one deterministic outcome per input on every filesystem, JDK,
and JIT state: a sparse hole reads back as zeros and fails the frame
CRC, a region past real end-of-file gives a short read, and a media
error gives a failed read -- each is the boundary of recoverable
data. The mapping is created only after the scan, for the append
path, whose writes materialize pages rather than faulting.
Reading the same regions through the mapping raises SIGBUS, which
HotSpot converts to an InternalError delivered at an imprecise point
under a JIT-compiled caller -- not reliably catchable by any
try/catch placement, which is the MmapSegmentRecoveryFaultTest flake
on the JDK 8 CI (#69). With no fault to catch, the
catchable-InternalError machinery (isMmapAccessFault, the table-CRC
fallback, the per-method catch arms) is gone, and the frame CRC uses
the native Crc32c again -- safe on a process-private buffer.
The scan is one pass through a sliding 1 MiB pread window (header
fields, lastGood, frame count, torn-tail probe together); frames
larger than the window CRC-fold across refills. The recovery tests
become single-outcome and gain a bad-sector case via the facade's
read seam (renamed MmapSegmentRecoveryBoundaryTest -- there is no
fault delivery left to branch on).
Fixes #69.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 5cc68a9 commit 0a345a1
6 files changed
Lines changed: 347 additions & 390 deletions
File tree
- core/src
- main/java/io/questdb/client
- cutlass/qwp/client/sf/cursor
- std
- test/java/io/questdb/client/test/cutlass/qwp/client/sf/cursor
Lines changed: 215 additions & 236 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
273 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
103 | 101 | | |
104 | 102 | | |
105 | 103 | | |
| |||
0 commit comments