E22F test(e2e): flush system.query_log before checking it by jsc0218 · Pull Request #2182 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

test(e2e): flush system.query_log before checking it - #2182

Merged
Slach merged 1 commit into
Altinity:0.28.0from
jsc0218:fix/flush-query-log-before-check
Dec 2, 2026
Merged

Slach merged 1 commit into
Altinity:0.28.0from
jsc0218:fix/flush-query-log-before-check

Conversation

@jsc0218
@jsc0218 jsc0218 commented Dec 1, 2026
Copy link
Copy Markdown

Fixes #2181

check_query_log reads system.query_log right away, but ClickHouse writes that table on a timer (7.5 s by default), so a statement the operator just ran can be missing. This made test_010014_0 fail once.

Run SYSTEM FLUSH LOGS ON CLUSTER 'all-sharded' first, since the check reads from cluster('all-sharded', ...).

@jsc0218
jsc0218 marked this pull request as ready for review December 1, 2026 22:49
@Slach Slach left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. This fix is needed. A query can't see entries that are still in the system log's in-memory buffer. Checked against the ClickHouse source:

  1. New log entries go into a private std::vector<LogElement> queue inside SystemLogQueue (SystemLogBase.h#L208). No storage reads that queue.
  2. The saving thread (SystemLog.cpp#L885) calls pop(). pop() waits for flush_interval_milliseconds or for an explicit flush (SystemLogBase.cpp#L288-L298).
  3. flushImpl() runs a regular INSERT into the system.query_log MergeTree table (SystemLog.cpp#L986-L1019). SELECT sees a row only after that INSERT is done.
  4. SYSTEM FLUSH LOGS waits until the queue has been flushed up to the current index (SystemLogBase.cpp#L231). The check reads cluster('all-sharded', system.query_log), so the flush has to run ON CLUSTER 'all-sharded' too, as this PR does.

@Slach
Slach merged commit b7db594 into Altinity:0.28.0 Dec 2, 2026
3 checks passed
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.

2 participants

0