Skip to content

Revert retention policy for clickhouse system.query_log.#10451

Open
jmcarp wants to merge 1 commit into
mainfrom
jmcarp/revert-query-log-ttl
Open

Revert retention policy for clickhouse system.query_log.#10451
jmcarp wants to merge 1 commit into
mainfrom
jmcarp/revert-query-log-ttl

Conversation

@jmcarp
Copy link
Copy Markdown
Contributor

@jmcarp jmcarp commented May 15, 2026

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.

@jmcarp jmcarp requested a review from bnaecker May 15, 2026 20:26
Copy link
Copy Markdown
Collaborator

@bnaecker bnaecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@jmcarp jmcarp force-pushed the jmcarp/revert-query-log-ttl branch from 2c02ace to 456d1ab Compare May 16, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clickhouse: updates to system.query_log ttl don't survive restart

2 participants