Repository navigation
Reduce peak memory of test 03216_arrayWithConstant_limits - #111705
Merged
Merged
Conversation
The final query built a single ~1.6 GiB block (100 rows, each with a 1-million-element `Array(Array(Int))` from `arrayWithConstant`), which fails with `MEMORY_LIMIT_EXCEEDED` on a loaded parallel test runner when the server is close to its total memory limit (the OvercommitTracker selects the query to stop). Cap `max_block_size` so the rows are processed in small blocks: the same code path is exercised with a peak allocation about a hundred times smaller. Failure example: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111103&sha=5f9a7dc8a262eab4e2268940baf6eb4afd6b3cd8&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29 (PR #111103)
Contributor
|
Workflow [PR], commit [bc44783] Summary: ✅ AI ReviewSummaryThis PR rewrites Final VerdictStatus: ✅ Approve |
The previous fix did not work: the flaky check on this PR still failed with MEMORY_LIMIT_EXCEEDED (a single 1.49 GiB chunk allocation), because the Memory engine returns stored blocks as-is and max_block_size cannot split a block that was already formed. CREATE TABLE ... AS SELECT ... FROM numbers(1, 100) stores a single 100-row block, so the query still built the whole ~1.6 GiB column at once. Store 2-row blocks at insert time (min_insert_block_size_rows = 2) and read with max_threads = 1 to bound the number of blocks in flight. Verified with clickhouse-local: the old query fails under a 500 MB memory cap with the same 1.49 GiB chunk as in CI, the new one passes under a 300 MB cap. Co-Authored-By: Claude Fable 5 <[email protected]>
Algunenano
approved these changes
Jul 24, 2026
…time limit The flaky check on this PR failed with "Test runs too long (> 180s)" under TSan: the final query generated 100 rows x 1 million-element arrays (~2.7 s in a release build, an order of magnitude slower with sanitizers, and the flaky check runs the test in a loop). Reduce the table to 10 rows, keeping the 1 million elements per array and the small stored blocks, so the same code path is exercised in ~0.13 s (release) and the test still passes under a 300 MB memory cap. Failure report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111705&sha=bfa62a7207e507c44fa18063934a9f1257f295c9&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29 Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Jul 24, 2026
This was referenced Jul 25, 2026
1 task
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…ithconstant-memory Reduce peak memory of test 03216_arrayWithConstant_limits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Reduce the peak memory usage and runtime of the test
03216_arrayWithConstant_limitsto stop it flaking withMEMORY_LIMIT_EXCEEDEDon loaded parallel runners.Documentation entry for user-facing changes
The final query of the test built a single ~1.6 GiB block (100 rows, each holding a 1-million-element
Array(Array(Int))produced byarrayWithConstant). On a loaded parallel runner, when the server's RSS is close to the total memory limit, the allocation fails withMEMORY_LIMIT_EXCEEDED(theOvercommitTrackerselects the query to stop).Setting
max_block_sizeon the finalSELECT(the first attempt in this PR) does not help: theMemoryengine returns its stored blocks unchanged, andCREATE TABLE ... AS SELECT ... FROM numbers(1, 100)stores a single 100-row block, so the flaky check on this PR still failed with the same single 1.49 GiB chunk allocation. Instead, the table is now populated with an explicitINSERT ... SELECTundermax_block_size = 2, min_insert_block_size_rows = 2, min_insert_block_size_bytes = 1, so it stores small two-row blocks, and the finalSELECTreads withmax_threads = 1to bound the number of blocks in flight.The second attempt (100 rows in two-row blocks) then failed the flaky check with
Test runs too long (> 180s)under TSan: generating 100 rows with 1-million-element arrays takes ~2.7 s in a release build, an order of magnitude more with sanitizers, and the flaky check runs the test in a loop. The table is therefore reduced to 10 rows, keeping the 1 million elements per array and the two-row stored blocks, so the same code path is exercised in ~0.13 s (release) with a peak allocation two orders of magnitude smaller than the original (verified withclickhouse-local: the old query fails under a 500 MB memory cap with the same 1.49 GiB chunk as in CI, the new one passes under a 300 MB cap).This is a broad master-side flake: on 2026-07-23 alone it failed on five unrelated pull requests (#93111, #111502, #111570, #111241, #110833), and 24 failures were recorded on 2026-07-15.
Failure example: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111103&sha=5f9a7dc8a262eab4e2268940baf6eb4afd6b3cd8&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29
Related: #111103
Version info
26.8.1.127(included in26.8and later)