Skip to content

Docs: mention that SYSTEM RESTORE REPLICA clears the server-wide caches - #134022

Merged
Blargian merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/docs-restore-replica-cache-flush
Nov 24, 2026
Merged

Blargian merged 4 commits into
ClickHouse:masterfrom
groeneai:groeneai/docs-restore-replica-cache-flush

Conversation

@groeneai

@groeneai groeneai commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #132791
Related: #132674

Changelog category (leave one):

  • Documentation (changelog entry is not required)

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

Document that SYSTEM RESTORE REPLICA clears the server-wide data caches.

Description

Follow-up to #132791, where @ PedroTadim asked to document its cache flush. The SYSTEM RESTORE REPLICA section now says that the statement clears the server-wide data caches for all tables on the server (with ON CLUSTER, on every server where the replica is restored), lists the cleared caches and names the two that are kept.

The page system.mdx is generated from ParserSystemQuery.cpp, so the paragraph is added there. The same flush also runs when a restore is started by the force_restore_data or convert_to_replicated flag while a table is loaded; replication.mdx is not changed here.

Validation: on a branch server the restore emptied the query condition cache and the mark cache of an unrelated table and kept the query cache; the regenerated page passes lychee_check.py and check_autogenerated_regions.py.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.12.1.390-master (included in 26.12 and later)

groeneai and others added 3 commits November 24, 2026 01:44
Since ClickHouse#132791, restoring a replica clears the server-wide data caches,
because the restored parts get new names that can be the former names and
paths of other parts. Document this in the SYSTEM RESTORE REPLICA section:
every table on the server starts with cold caches, every server with
ON CLUSTER, and the query cache and the filesystem cache are kept. The
cleared caches are listed with links to their SYSTEM CLEAR sections.

The reference page docs/reference/statements/system.mdx is generated from
the documentation in ParserSystemQuery.cpp, so the paragraph is added there.

Related: ClickHouse#132791

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Context::clearCaches also clears the encryption headers cache and the
UNIQUE KEY delete bitmap cache, so "other caches are kept" was wrong. List
the encryption headers cache with the other cleared caches and name only
the query cache and the filesystem cache as kept. With ON CLUSTER, the
caches are cleared only on the servers where the restore actually runs.

Related: ClickHouse#132791

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… RESTORE REPLICA clears

Context::clearCaches clears the UNIQUE KEY delete bitmap cache too; it has no
SYSTEM CLEAR statement, so it is listed without a link.

Related: ClickHouse#132791

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)
Finding Verdict
⚠️ "Other caches, such as the query cache and the filesystem cache, are kept" implied that every unlisted cache is kept, but the restore also clears the encryption headers cache and the UNIQUE KEY delete bitmap cache AGREE, fixed: both are listed, the sentence names only the two kept caches
⚠️ "Their next queries start with cold caches" is not guaranteed while other reads run DISAGREE: the sentence describes the performance effect; reworded to "queries on them have to fill the caches again"
💡 "With ON CLUSTER, every server" holds only where the restore passes its checks AGREE, fixed: "on every server where the replica is restored"

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? N/A for a failure (docs-only). The documented behaviour is shown on demand on a server built from this branch: after SYSTEM RESTORE REPLICA t, system.query_condition_cache goes 1 -> 0, MarkCacheBytes 384 -> 0, and the next query on an unrelated table misses the mark cache, while a control query with no restore in between hits it.
b Root cause explained? The reference text predates #132791, which made the restore call Context::clearCaches(); the page system.mdx is generated from ParserSystemQuery.cpp.
c Fix matches root cause? Yes: the paragraph is added to the generator's source, not to the generated page.
d Test intent preserved / new tests added? No test (docs-only). 04926_system_statements passes; 04927_system_documentation_statements differs only in its source-path check, which fails the same way on a local master build (absolute build paths).
e Both directions demonstrated? The master binary has no such paragraph in system.documentation, the branch binary has it; the regenerated page differs by exactly the paragraph; the link check reports a deliberately broken anchor and passes on the real ones.
f Fix is general across code paths? Every listed cache was checked against Context::clearCaches, including the encryption headers and UNIQUE KEY delete bitmap caches; the query cache and the filesystem cache are not cleared there. The other two restore callers (force_restore_data, convert_to_replicated) are named in the description.
g Fix generalizes across inputs (params/datatypes/wrappers)? ON CLUSTER observed on a one-node cluster (same flush on the executing host); the list now names every cache Context::clearCaches clears, and only the query cache and the filesystem cache are claimed kept.
h Backward compatible? (maintainer-approved exception only) Yes, documentation text only.
i Invariants and contracts preserved? The raw string literal stays under the 65,536-byte limit (34,584 B), no AUTOGENERATED region is edited (check_autogenerated_regions.py passes), all new in-page anchors resolve.

Session id: cron:clickhouse-impl-slot-4:20261124-030100

@clickhouse-gh

clickhouse-gh Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [983da42]

Summary: ✅


AI Review

Summary

This documentation-only change explains that SYSTEM RESTORE REPLICA clears data caches for all tables on the executing server, lists the affected caches, and identifies the query and filesystem caches as retained. The text matches the current restore implementation and updates the source registration used to generate the reference page. All prior discussion and the current diff were reviewed; no actionable findings remain at 983da42b07a78b553acf80792be3acb8dc38f77a.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-documentation Documentation PRs for the specific code PR can be tested Allows running workflows for external contributors comp-documentation Documentation (docs, examples, READMEs). labels Nov 24, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 983da42b0 with master 1c69de598 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 6 s compile time in total, 7 of them have a recent master baseline.

Job report

Comment thread src/Parsers/ParserSystemQuery.cpp Resolved
@Blargian

Copy link
Copy Markdown
Member

@groeneai no action required for this PR but I would like you to remember the following about writing docs:

Keep text short and scannable.

  • One idea per sentence. If a sentence runs past about 25 words, split it.
  • If a sentence contains more than 3 parallel items, make it a bulleted list.
  • If a paragraph is more than 3-4 sentences, split it or cut it.
  • Put the key point first, and cut anything that doesn't change what the reader does or understands.
  • Use plain, direct words. No filler, no hedging, no marketing tone.

Please update your memory about this if possible.

@Blargian
Blargian enabled auto-merge November 24, 2026 10:30
@groeneai

Copy link
Copy Markdown
Collaborator Author

Saved to my memory. I'll apply these rules to all docs text I write, including the documentation strings in source files like this one.

@Blargian
Blargian added this pull request to the merge queue Nov 24, 2026
Merged via the queue into ClickHouse:master with commit 08d32b7 Nov 24, 2026
194 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 24, 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-documentation Documentation (docs, examples, READMEs). pr-documentation Documentation PRs for the specific code 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.

3 participants