Revert retention policy for clickhouse system.query_log.#10451
Merged
Conversation
bnaecker
approved these changes
May 15, 2026
Collaborator
bnaecker
left a comment
There was a problem hiding this comment.
LGTM, thanks. We should make sure we have a way to drop the "helpfully" renamed system.query_log_$N tables on customer systems.
As described in #10444, there's a bug in setting retention policies on `system.query_log`: because we configure the ttl in config.xml and then optionally overwrite it in sql via retention policies, user-configured ttls on the query log table don't survive clickhouse restarts. Instead, clickhouse moves `system.query_log` to `system.query_log_$ORDINAL`, and creates a new `system.query_log` table using the ttl from config.xml. We could solve this by persisting the user-configured ttl in cockroachdb and propagating that value to config.xml somehow. However, it's simpler to instead make `system.query_log` small enough that we don't have to care about its ttl, and remove it from the retention policy concept. We dropped the size of this table significantly in #10443, and will drop it further by omitting query logs for fast queries in a follow-up patch. In this patch, we drop logic to manage the query log ttl. Fixes #10444.
2c02ace to
456d1ab
Compare
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.
As described in #10444, there's a bug in setting retention policies on
system.query_log: because we configure the ttl in config.xml and then optionally overwrite it in sql via retention policies, user-configured ttls on the query log table don't survive clickhouse restarts. Instead, clickhouse movessystem.query_logtosystem.query_log_$ORDINAL, and creates a newsystem.query_logtable using the ttl from config.xml.We could solve this by persisting the user-configured ttl in cockroachdb and propagating that value to config.xml somehow. However, it's simpler to instead make
system.query_logsmall enough that we don't have to care about its ttl, and remove it from the retention policy concept. We dropped the size of this table significantly in #10443, and will drop it further by omitting query logs for fast queries in a follow-up patch. In this patch, we drop logic to manage the query log ttl.Fixes #10444.