Skip to content

Fix flaky 03642_system_instrument_multiple_handlers test - #99672

Merged
Algunenano merged 4 commits into
ClickHouse:masterfrom
Algunenano:fix-instrument-multiple-handlers-test
Mar 17, 2026
Merged

Algunenano merged 4 commits into
ClickHouse:masterfrom
Algunenano:fix-instrument-multiple-handlers-test

Conversation

@Algunenano

@Algunenano Algunenano commented Mar 16, 2026 •

Copy link
Copy Markdown
Member

Fix flaky 03642_system_instrument_multiple_handlers test.

The message ILIKE '%InstrumentationManager%Log%' filter relied on "InstrumentationManager" appearing in the stack trace text of the message column. This is fragile because stack trace symbol resolution varies across environments — the EXIT handler's stack frames may not resolve to include those symbol names (e.g., XRay trampoline frames may show as hex addresses). Replaced with logger_name = 'InstrumentationManager' AND message LIKE 'Log%' which uses the structured logger_name column instead.

Also added missing ORDER BY event_time_microseconds — without it the result order was non-deterministic.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99630&sha=64d0cff0ab4cff3ac550098a39069ded208ab299&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20sequential%29
#99630

cc @pamarcos

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.3.1.765

The test had two issues:

1. The ILIKE filter `%InstrumentationManager%Log%` on the `message` column
   relied on "InstrumentationManager" appearing in the stack trace text,
   which is fragile — stack trace symbol resolution varies across builds
   and the EXIT handler's stack frames may not resolve to include those
   symbol names. Replaced with `logger_name = 'InstrumentationManager'
   AND message LIKE 'Log%'` which uses the structured column.

2. Missing ORDER BY caused non-deterministic result ordering.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99630&sha=64d0cff0ab4cff3ac550098a39069ded208ab299&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20distributed%20plan%2C%20s3%20storage%2C%20sequential%29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [19f353b]

Summary: ✅


AI Review

Summary

This PR reduces flakiness in two stateless tests: one SYSTEM INSTRUMENT test now filters system.text_log by structured fields and deterministic ordering, and one TTL test replaces today() with a fixed far-future date. I did not find actionable correctness, safety, concurrency, or performance issues in the patch.

Missing context

  • ⚠️ No CI logs or test report links were provided in the review request.

ClickHouse Rules

Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsHistory.cpp ➖
Safe rollout ✅
Compilation time ✅

Final Verdict

  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Mar 16, 2026
alexey-milovidov and others added 2 commits March 17, 2026 01:35
The test `04004_alter_modify_column_ttl_without_type` uses `today()` which
makes the test non-deterministic and can cause failures around midnight
or in different timezones.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to reduce flakiness in the 03642_system_instrument_multiple_handlers stateless test by making log filtering less environment-dependent and ensuring deterministic result ordering.

Changes:

  • Update 03642_system_instrument_multiple_handlers.sh to filter system.text_log by structured logger_name + message prefix instead of relying on stack-trace text, and add an ORDER BY event_time_microseconds.
  • Adjust test data in 04004_alter_modify_column_ttl_without_type.sql to use a fixed “valid” date instead of today().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/queries/0_stateless/03642_system_instrument_multiple_handlers.sh Makes the text_log query more robust (structured filtering) and deterministic (explicit ordering).
tests/queries/0_stateless/04004_alter_modify_column_ttl_without_type.sql Changes inserted “valid” date value from dynamic today() to a fixed date literal.

ORDER BY uid;

INSERT INTO alter_modify_column_ttl_without_type VALUES (1, 'expired', '2000-01-01'), (2, 'valid', today());
INSERT INTO alter_modify_column_ttl_without_type VALUES (1, 'expired', '2000-01-01'), (2, 'valid', '2099-01-01');
SYSTEM INSTRUMENT REMOVE ALL;
SYSTEM FLUSH LOGS system.text_log;
SELECT extract(message, '.*\): (.+)\nStack trace.*') FROM system.text_log WHERE event_date >= yesterday() AND event_time >= now() - 600 AND query_id = '$query_id' AND message ILIKE '%InstrumentationManager%Log%';
SELECT extract(message, '.*\): (.+)\nStack trace.*') FROM system.text_log WHERE event_date >= yesterday() AND event_time >= now() - 600 AND query_id = '$query_id' AND logger_name = 'InstrumentationManager' AND message LIKE 'Log%' ORDER BY event_time_microseconds;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👌
this is one of those times I wondered how it even worked before

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I was looking for a content of the stack trace that contained both InstrumentationManager and then the Log line to make sure it came from the InstrumentationManager. But it's true that filtering by the logger_name is just simpler.

@Algunenano
Algunenano added this pull request to the merge queue Mar 17, 2026
Merged via the queue into ClickHouse:master with commit 6144c15 Mar 17, 2026
159 checks passed
@Algunenano
Algunenano deleted the fix-instrument-multiple-handlers-test branch March 17, 2026 19:46
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

6 participants