fix(core): fix crash on column type conversion under low disk space - #7537
Conversation
ColumnTypeConverter.convertFixedToFixed sized the destination column file with ff.truncate() before mapping it for a native write. truncate only sets the logical file length; it does not reserve real disk blocks. Under disk pressure, a native write into an unbacked page faults with SIGBUS, which is uncatchable from Java/JNI and aborts the whole process. TableUtils.allocateDiskSpace() reserves real blocks via posix_fallocate and raises a catchable CairoException when it can't, matching every other writable-mmap call site in the codebase (TableUtils.mapRW, ContiguousFileFixFrameColumn, MemoryCMARWImpl, O3PartitionJob). convertFixedToFixed now calls the same helper. Adds a regression test asserting the destination column file's disk space is reserved before it is mapped for writing.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[PR Coverage check]😍 pass : 1 / 1 (100.00%) file detail
|
Review (level 3)Submodule provenance: no submodule pointer changed in this PR's diff ( CriticalNone. ModerateProblem: New regression test never exercises
Suggested fix: add a gated MinorNew test doesn't guard with Adjacent findings (not blocking — pre-existing, not introduced by this PR)1.
Same file, same root cause, same one-line fix pattern — worth considering for this PR rather than a follow-up, given it's the exact crash this PR's title claims to close. 2. The destination-file mmap allocation isn't wired into the per-query
Coverage mapOne admitted gap (the SummaryVerdict: approve with comments. No open Critical findings; test gate passes (no admitted Critical coverage gap). The production fix itself ( The Moderate item (testing the actual |
|
/azp run macwin |
Review (level 3)Submodule provenance: no submodule pointer changed in this PR's diff ( CriticalNone. ModerateProblem: New regression test never exercises The test proves MinorNew test doesn't guard with Adjacent findings (not blocking — pre-existing, not introduced by this PR)
Worth folding into this PR rather than a follow-up, given it's the exact crash class this PR's title claims to close, in the same file, with the same one-line fix. Coverage mapOne admitted gap (the SummaryVerdict: approve with comments. No open Critical findings; test gate passes (no admitted Critical coverage gap). The production fix ( The Moderate item (untested |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Summary
ALTER TABLE ... ALTER COLUMN ... TYPEcrashed the whole JVM with anative SIGBUS when disk space was low, instead of failing the
statement with a normal error. The destination column file was sized
with
ftruncate(), which only sets the logical file length and doesnot reserve real disk blocks; a later native write into an unbacked
page faults with SIGBUS, which cannot be caught from Java/JNI. The fix
switches to
TableUtils.allocateDiskSpace()(posix_fallocate),matching every other writable-mmap call site in the codebase, so a
disk-space shortfall now surfaces as a catchable
CairoException.Crash
Test plan
AlterTableChangeColumnTypeTest#testConvertFixedToFixedReservesDiskSpaceBeforeMappingasserts the destination column file's disk space is reserved viaff.allocate()before it is mapped for writingAlterTableChangeColumnTypeTestsuite passes (87 tests)QwpIngressProcessorStateTest#testAlterColumnTypeWithBufferedRowsAppliesOnNextLookuppasses, confirming the WAL-buffered-rows call path through the same fixed method is unaffected