Skip to content

Add test: RESTORE into non-empty temporary Memory table: old+new limit check untested - #124887

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr124587
Oct 28, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr124587

Conversation

@clickgapai

@clickgapai clickgapai commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Test-only PR. Review: are the gaps real, is the test right.

Adds test coverage for 1 untested code path, found during automated review of PR #124587.
That PR: (1) RESTORE TEMPORARY TABLE now enforces the temporary-table limits with the RESTORE query's settings: StorageMemory::restoreDataImpl checks max_temporary_table_memory_usage on existing + restored bytes; StorageMergeTree::attachRestoredParts checks …

1. RESTORE into non-empty temporary Memory table: old+new limit check untested
src/Storages/StorageMemory.cpp:749, src/Storages/StorageMemory.cpp:662
Risk: 05339 only restores into empty tables, so the existing-data term of the check is always 0. restoreDataImpl checks old_and_new_data->bytes (StorageMemory.cpp:749); checking new_bytes alone passes every current test. - Risk: a refactor that hoists the check above the copy of the old …
Unique vs PR tests: 05339 restores only into a table it just dropped, so the existing size is 0 and the old+new sum is never tested. This test restores into a non-empty table where each side fits and the sum does not. It uses the Memory backup engine so it runs as .sql; it can go into 05339 if a separate file …
Try it on ClickHouse Fiddle

cc @alexey-milovidov (author of #124587) — could you take a look, and add the can be tested label if this looks good?

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Workflow [PR]
Sync PR [sync-upstream/pr/124887]

Version info

  • Merged into: 26.11.1.851-master (included in 26.11 and later)

@clickgapai

Copy link
Copy Markdown
Contributor Author
Pre-PR validation: 6/6 ✅

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Storages/StorageMemory.cpp:744-749: old_and_new_data->bytes += new_bytes; then checkTemporaryTableMemoryUsage(old_and_new_data->bytes, ...). The old-data term is non-zero only when allow_non_empty_tables lets the restore past the non-empty guard at line 662, and no test does that for a temporary table.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 05346_temporary_table_limits_restore_memory_non_empty.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@clickgapai
clickgapai force-pushed the qa-bot/coverage-pr124587 branch from c45181e to 086e8c9 Compare October 9, 2026 11:55
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 9, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f3888c7]

Summary: ✅


AI Review

Summary

Adds focused stateless coverage for RESTORE into a non-empty temporary Memory table: existing and restored data each fit the limit, their sum is rejected without changing the row count, and restoring after truncation succeeds. The previous engine-rewriting finding is addressed by the memory-engine tag. No outstanding findings. The new test passed in Fast test at the current PR head.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 18, 2026
@clickgapai

Copy link
Copy Markdown
Contributor Author

CI failure in Stateless tests (arm_binary, AsyncInsert, s3 storage, parallel) appears to be unrelated breakage and is not related to this change. Let me know if you'd like me to merge master and retrigger CI.

@groeneai groeneai mentioned this pull request Oct 19, 2026
1 task done
@alexey-milovidov alexey-milovidov self-assigned this Oct 25, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

No new PR is needed: both red checks on 086e8c9f ran on a tree without the fixes.

They come from run 37926788789, attempt 2, re-run on 2026-10-18. The run was created on 2026-10-09, and a re-run tests the original merge commit, a1201ea1dc44 (086e8c9f merged with master ea30d777, 2026-10-09 11:05 UTC). That tree has neither #124935 (merged 2026-10-10) nor #124920 (merged 2026-10-11). I checked the tested tree directly: both test files are still the pre-fix versions.

Since the fixes merged, each of these failures ran on a tree without the fix: 4 for 05239 and 2 for 05317. The one other 05317 failure, on #106734, came from that PR's own use_reader_executor randomization. Neither test has failed since 2026-10-18 06:25 UTC: 30,429 OK runs of 05239 and 34,398 of 05317, including 4,698 each on master. Your master merge a00c85c6 contains both fixes.

@clickgapai

Copy link
Copy Markdown
Contributor Author

No separate PR needed: @groeneai's reply above covers both checks, and both fixes (#124920, #124935) are in the latest commit.

The only open item on this PR is the new AI review P2 on line 4 (missing -- Tags: memory-engine). It has its own thread.

Stress runs with --replace-log-memory-with-mergetree rewrite ENGINE = Memory
to MergeTree, which does not enforce max_temporary_table_memory_usage, so the
expected TOO_MANY_BYTES on the first RESTORE never fires.

Requested by @clickhouse-gh[bot] in ClickHouse#124887 (comment)
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 The only red check, Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) → Some queries hung, is unrelated to this test-only PR. The hung query was a parallel-replicas subquery from 04117_detach_database_kill_query (initial_query_id: select_04117_test_..., sleepEachRow(3), still running after 284 s), and the new test 05346_temporary_table_limits_restore_memory_non_empty passed in the same run. The same failure shows up on many other PRs and on master. A fix is in progress in #127149.

Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124887&sha=eaa55df896b3c811cf5ede91ef91781e84d8b06a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged the latest master to refresh CI. The only red check was Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel) → Some queries hung. The hung query came from 04117_detach_database_kill_query (select_04117_test_*), not from this test-only PR. That flakiness is addressed by #127935, which is now on master and included in this branch.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 28, 2026
Merged via the queue into ClickHouse:master with commit 520ae01 Oct 28, 2026
179 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 28, 2026
@clickhouse-gh clickhouse-gh Bot added comp-simple-engines Lightweight single-node table engines: Log/StripeLog (append-only logs), Buffer (async batching),... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-simple-engines Lightweight single-node table engines: Log/StripeLog (append-only logs), Buffer (async batching),... pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants