Skip to content

cleanup temporary table entry from snapshot_detached_tables during table drop#88617

Merged
nickitat merged 2 commits intoClickHouse:masterfrom
pranavmehta94:pranav/global-in-fix
Oct 17, 2025
Merged

cleanup temporary table entry from snapshot_detached_tables during table drop#88617
nickitat merged 2 commits intoClickHouse:masterfrom
pranavmehta94:pranav/global-in-fix

Conversation

@pranavmehta94
Copy link
Copy Markdown
Contributor

@pranavmehta94 pranavmehta94 commented Oct 16, 2025

Temporary tables are auto-created when using distributed queries with GLOBAL IN. These tables use the Memory Database engine and are passed to remote servers during distributed query processing.
In DatabaseMemory::dropTable, when a table is dropped, the cleanup steps are as follows:

  • Removes from tables map (via detachTableUnlocked)
  • Removes create query from create_queries map
  • Removes UUID mapping from UUID registry
  • Missing cleanup: detached table entry remains in snapshot_detached_tables

This residual metadata is retained indefinitely, leading to a memory leak proportional to the rate of temporary table creation.

This PR does the following:

  • Modify DatabaseMemory::dropTable to ensure complete cleanup by erasing detached table entry from snapshot_detached_tables

This PR fixes #88615

Changelog category (leave one):

  • Improvement

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

Fixes memory leak due to GLOBAL IN (#88615)

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Oct 16, 2025

CLA assistant check
All committers have signed the CLA.

@nickitat nickitat self-assigned this Oct 16, 2025
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Oct 16, 2025

Workflow [PR], commit [2392a94]

Summary:

job_name test_name status info comment
Finish Workflow failure
python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py failure

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 16, 2025
@nickitat nickitat added the can be tested Allows running workflows for external contributors label Oct 16, 2025
@nickitat nickitat added this pull request to the merge queue Oct 17, 2025
Merged via the queue into ClickHouse:master with commit c89792d Oct 17, 2025
238 of 242 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 17, 2025
@nickitat nickitat added pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-cloud labels Oct 18, 2025
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Oct 18, 2025
robot-ch-test-poll3 added a commit that referenced this pull request Oct 18, 2025
Cherry pick #88617 to 25.3: cleanup temporary table entry from snapshot_detached_tables during table drop
robot-clickhouse added a commit that referenced this pull request Oct 18, 2025
robot-ch-test-poll3 added a commit that referenced this pull request Oct 18, 2025
Cherry pick #88617 to 25.7: cleanup temporary table entry from snapshot_detached_tables during table drop
robot-clickhouse added a commit that referenced this pull request Oct 18, 2025
robot-ch-test-poll3 added a commit that referenced this pull request Oct 18, 2025
Cherry pick #88617 to 25.8: cleanup temporary table entry from snapshot_detached_tables during table drop
robot-clickhouse added a commit that referenced this pull request Oct 18, 2025
robot-ch-test-poll3 added a commit that referenced this pull request Oct 18, 2025
Cherry pick #88617 to 25.9: cleanup temporary table entry from snapshot_detached_tables during table drop
robot-clickhouse added a commit that referenced this pull request Oct 18, 2025
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 18, 2025
clickhouse-gh bot added a commit that referenced this pull request Oct 18, 2025
Backport #88617 to 25.7: cleanup temporary table entry from snapshot_detached_tables during table drop
nickitat added a commit that referenced this pull request Oct 20, 2025
Backport #88617 to 25.9: cleanup temporary table entry from snapshot_detached_tables during table drop
nickitat added a commit that referenced this pull request Oct 20, 2025
Backport #88617 to 25.8: cleanup temporary table entry from snapshot_detached_tables during table drop
nickitat added a commit that referenced this pull request Oct 20, 2025
Backport #88617 to 25.3: cleanup temporary table entry from snapshot_detached_tables during table drop
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 pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

GLOBAL IN causes Memory Leak

6 participants