Repository navigation
Keep the non spillable bytes of PackedFilesWriter consistent if a chunk allocation throws - #127375
Conversation
…hunk allocation throws `Data::addChunk` stopped counting the previous last chunk as non spillable before allocating the new chunk. If the allocation threw (e.g. `MEMORY_LIMIT_EXCEEDED`), the previous chunk stayed the last one, and the destructor subtracted it again, so `non_spillable_bytes_in_memory` wrapped around and skewed the spill decisions. Allocate the new chunk first. Found by the UBSan check for unsigned integer overflows in #120906. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [92553cd] Summary: ✅
AI ReviewSummaryThe PR allocates the next chunk before changing Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 6 s compile time in total, 7 of them have a recent master baseline. |
alexey-milovidov
left a comment
There was a problem hiding this comment.
This is just to avoid underflow on subtraction.
|
🕵 The |
|
🕵 The |
|
🕵 Merged master. The remaining failures on |
|
🕵 Merged master to pull in #127781, which fixes the only failure on |
|
🕵 Merged master ( |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127375&sha=adf15b0e53fd7cd97457bd99d88af65f19ab0eaa&name_0=PR&name_1=Build%20profile%20diff ( |
|
The red on The job-side fix, which keeps the check green when the probe itself gets the 241, is your #128067; my #126200 covers the same case, so no other PR is needed. |
PackedFilesWriter::Data::addChunkstopped counting the previous last chunk as non spillable before allocating the new chunk. If the allocation threw (e.g.MEMORY_LIMIT_EXCEEDED), the previous chunk stayed the last one, and the destructor ofDatasubtracted it again, sonon_spillable_bytes_in_memorywrapped around and skewed the spill decisions of the writer of packed parts. The new chunk is now allocated first.There is no test: the allocation has to fail exactly at a chunk boundary. It was found by the UBSan check for unsigned integer overflows in a stress test.
Related: #120906
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix the memory accounting of the writer of packed data parts after a failed memory allocation, which could make it spill to disk too much or too little.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127375]
Version info
26.11.1.906-master(included in26.11and later)