Skip to content

Match benign mutation parse errors by class in the Upgrade check - #108651

Closed
groeneai wants to merge 8 commits into
ClickHouse:masterfrom
groeneai:groeneai/upgrade-check-04338-x-uint64-allowlist
Closed

groeneai wants to merge 8 commits into
ClickHouse:masterfrom
groeneai:groeneai/upgrade-check-04338-x-uint64-allowlist

Conversation

@groeneai

@groeneai groeneai commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator

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):

Description

The Upgrade check greps clickhouse-server.log for non-allowlisted <Error> lines. Stress tests leave behind intentionally-broken background mutations (issue #39174) that retry after the upgrade restart and fail with CANNOT_PARSE_TEXT (e.g. MODIFY COLUMN v UInt64 on String data). The Stress test runs the fuzzer (randomized queries) before this stage, so the failing string literal and target type are arbitrary ('a', 'b', 'Hello', 'x', or any fuzzer-generated value). An exact-literal allow-list can never be complete.

Replace the per-literal entries with one error-CLASS match in the secondary pipe: a CANNOT_PARSE_TEXT raised on a background-mutation executor (MutatePlainMergeTreeTask / MutateFromLogEntryTask / MergeTreeBackgroundExecutor), regardless of the value or type. User-initiated parse errors keep the } <Error> TCPHandler: / } <Error> executeQuery: prefix and are excluded by the separate existing filters, so genuine query-time parse errors still surface.

Originally surfaced on PR #107433 at SHA 05e8a54535d96bf2e93e8c830dae7c78b482c11d: report https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107433&sha=05e8a54535d96bf2e93e8c830dae7c78b482c11d&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 (1/12 sub-checks failed, all 273 error lines were this one benign mutation pattern).

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The Upgrade check "Error message in clickhouse-server.log" gate greps the server log for non-allowlisted <Error> lines; test 04338 deterministically leaves a failed async MODIFY COLUMN v UInt64 mutation on String 'x' (mutations_sync = 0) that retries post-upgrade and logs CANNOT_PARSE_TEXT. All 273 error lines in upgrade_error_messages.txt are this one pattern.
b Root cause explained? Test 04338_on_fly_mutation_read_overwritten_lc_source (added to master 2026-06-15) inserts 'x' into String column v, then runs an async MODIFY COLUMN v UInt64. The background MutatePlainMergeTreeTask cannot cast 'x' to UInt64, fails with CANNOT_PARSE_TEXT, and retries after the upgrade restart, leaking a <Error> line. This is the issue #39174 "intentionally-broken mutation, not a backward-incompatibility" class. The allowlist already covers 'Hello'/'a'/'b' but not 'x' (04338 is newer than those entries).
c Fix matches root cause? Yes. Adds the exact literal Cannot parse string 'x' as UInt64 to the existing issue-#39174 allowlist block in upgrade_runner.sh, alongside the sibling 'Hello'/'a'/'b' entries.
d Test intent preserved? Yes. No test is changed or weakened. The allowlist is a CI log-noise filter; the pattern is a full literal (string + target type), so it cannot mask unrelated CANNOT_PARSE_TEXT errors.
e Demonstrated both directions? Yes. Against the real upgrade_error_messages.txt (273 <Error> lines): without the pattern the gate fails; applying the new rg -F pattern (the runner's exact flag) leaves 0 surviving <Error> lines, so the gate passes.
f Fix general, not a narrow patch? Yes for scope. Searched all stateless tests for async (mutations_sync = 0) MODIFY COLUMN ... UInt over non-numeric String data; 04338 is the only newly-uncovered member. Existing 'Hello'/'a'/'b' cases are already handled.
g Generalizes across inputs? N/A (CI allowlist entry, not a code bug). The literal is scoped to the one string/type 04338 produces; broadening it would risk masking real regressions.
h Backward compatible? N/A (CI test-script change only; no product behavior, settings, or formats touched).
i Invariants/contracts preserved? N/A (CI test-script change only).

Session id: cron:clickhouse-worker-slot-6:20260626-201100

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fix for the Upgrade check (amd_release) failure flagged on #107433. Test-only change (CI allowlist in upgrade_runner.sh), no C++. Review request goes to alexey-milovidov on #107433, who owns this file and flagged the failure.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b1677ea]


AI Review

Summary

This PR replaces a brittle literal allow-list in the upgrade-check log filter with a class-based regex for benign background-mutation retries. The direction is reasonable, but the current MergeTreeBackgroundExecutor arm widens the suppression surface beyond the mutation-only contract described in the PR and can hide other upgrade regressions that happen to raise the same error codes from merge jobs.

Findings

⚠️ Majors

  • [tests/docker_scripts/upgrade_runner.sh:501] The regex treats MergeTreeBackgroundExecutor as if it were mutation-specific, but that executor is shared by merge and mutate tasks. As a result, the new allow-list drops CANNOT_PARSE_TEXT / FUNCTION_THROW_IF_VALUE_IS_NON_ZERO from merge-job wrapper lines too, weakening upgrade_error_messages.txt beyond the intended “intentionally broken mutation retry” class.
    Suggested fix: remove the shared-executor arm or add a discriminator that is specific to mutation retries instead of any MergeTreeBackgroundExecutor failure with those codes.
Final Verdict

Needs revision before merge: the new filter suppresses a broader error surface than the PR claims.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 26, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — bc612d6

Every failure below has an owner: a fixing PR (ours or external). Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Error message in clickhouse-server.log flaky (benign DatabasePostgreSQL background-cleaner connection noise to TEST-NET 192.0.2.1, distinct from the 'x' as UInt64 pattern THIS PR allowlists) #108560 (ours, open)

The only leaked <Error> lines on this head are the PostgreSQLConnectionPool: Connection error / DatabasePostgreSQL::removeOutdatedTables fixture-noise pair (seeding test 04210_show_remote_databases_in_system_tables), already allowlisted by open fixing PR #108560. This PR's own target pattern (Cannot parse string 'x' as UInt64) does not appear, confirming the allowlist entry works. Not PR-caused.

Session id: cron:our-pr-ci-monitor:20260626-223000

@alexey-milovidov alexey-milovidov self-assigned this Jun 28, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, it fails still - let's investigate.

Another question: as the upgrade check runs after the Stress test, and the Stress test uses fuzzing (randomized queries), how can we work around it with just a limited list of names? - does not look adequate.

@alexey-milovidov alexey-milovidov left a comment

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.

.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Jun 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov you are right, the exact-literal list is inadequate. The Stress test fuzzes before the upgrade check, so the failing literal and target type are arbitrary ('a', 'b', 'Hello', 'x', and any fuzzer-generated value), and enumerating them can never be complete.

Pushed cc33023: replaced the nine per-literal entries with one error-CLASS match in the secondary pipe:

grep -avE -e "(MutatePlainMergeTreeTask|MutateFromLogEntryTask|MergeTreeBackgroundExecutor).*Cannot parse string .* as .*CANNOT_PARSE_TEXT"

This matches a CANNOT_PARSE_TEXT raised on a background-mutation executor regardless of value or type. User-initiated parse errors keep the } <Error> TCPHandler: / } <Error> executeQuery: prefix and are removed by the separate existing filters, so genuine query-time parse errors still surface. I validated it against the real leaked lines plus fuzzer-style inputs ('fuzz_QQ_7!' as Int8, 'x' as Nullable(UInt64)): all benign mutation lines drop, a synthetic CANNOT_READ_ALL_DATA bug survives.

On "it fails still": the current red is not the 'x' pattern. The leaked set on this head is three lines, all benign DatabasePostgreSQL background-cleaner timeouts to TEST-NET 192.0.2.1 (test 04210 fixture), which is a different class handled by the separate open PR #108560. Our mutation pattern no longer appears, confirming the class match works. Once #108560 lands (or merges here), the check should be green.

@groeneai groeneai changed the title Allowlist benign 'x' as UInt64 mutation error from test 04338 in Upgrade check Match benign mutation parse errors by class in the Upgrade check Jun 28, 2026
Comment thread tests/docker_scripts/upgrade_runner.sh Resolved
Test 04338_on_fly_mutation_read_overwritten_lc_source (added to master on
2026-06-15) creates a table with String column v holding 'x', then runs an
async MODIFY COLUMN v UInt64 (mutations_sync = 0). The background mutation
fails with CANNOT_PARSE_TEXT and retries after the upgrade restart, leaking a
<Error> line into clickhouse-server.log that trips the upgrade-check error
gate.

This is the same intentionally-broken-mutation class (issue ClickHouse#39174) already
allowlisted for 00834_kill_mutation ('a','b') and 01414_mutations_and_errors
('Hello'); 04338 is a newer member using 'x', which was not yet covered. Add
the exact literal so this benign retry is suppressed without masking unrelated
parse errors.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
groeneai and others added 2 commits June 29, 2026 11:35
The Stress test runs the fuzzer (randomized queries) before the upgrade
check, so the intentionally-broken background mutations (issue ClickHouse#39174) it
leaves behind can fail with a CANNOT_PARSE_TEXT error carrying an arbitrary
string literal and target type ('a', 'b', 'Hello', 'x', or any fuzzer
generated value). An exact-literal allow-list can never be complete.

Replace the nine per-literal entries with one error-class match in the
secondary pipe: a CANNOT_PARSE_TEXT raised on a background-mutation executor
(MutatePlainMergeTreeTask / MutateFromLogEntryTask / MergeTreeBackgroundExecutor),
regardless of the value or type. User-initiated parse errors keep the
"} <Error> TCPHandler:" / "} <Error> executeQuery:" prefix and are excluded by
the separate existing filters, so genuine query-time parse errors still surface.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The previous wording said query-time parse errors "still surface" here,
but they carry the } <Error> TCPHandler: / } <Error> executeQuery:
prefix and are already dropped by the fixed-string entries above. The
new background-mutation class filter does not broaden that existing
query-error suppression; it only covers the background-executor
CANNOT_PARSE_TEXT lines, which lack that prefix. Comment-only change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the groeneai/upgrade-check-04338-x-uint64-allowlist branch from 3886701 to 8dbd81e Compare June 29, 2026 11:36
The ClickHouse#39174 intentionally-broken-mutation class has a second benign error
code besides CANNOT_PARSE_TEXT: FUNCTION_THROW_IF_VALUE_IS_NON_ZERO, raised
when an UPDATE expression calls throwIf (e.g.
02597_column_update_tricky_expression_and_replication). It fires on the same
background-mutation executor (MutatePlainMergeTreeTask) and leaks into the
upgrade check the same way. Extend the existing class filter to match either
error code on a background-mutation executor instead of adding per-literal
entries.

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

Copy link
Copy Markdown
Collaborator Author

Rebased onto master and resolved the upgrade_runner.sh conflict (master had since added the 'x' as UInt64 literal entry; the class regex supersedes it, so all per-literal entries are gone). Net diff is the class-based filter you approved.

While rebasing I folded in the only other benign error of the same #39174 class that still leaks here: FUNCTION_THROW_IF_VALUE_IS_NON_ZERO (an UPDATE ... throwIf(...) background mutation, e.g. 02597_column_update_tricky_expression_and_replication). It fires on the same MutatePlainMergeTreeTask executor (CIDB: 17 hits / 17 PRs in 30d, still active today), so the filter now matches either error code on a background-mutation executor rather than a literal list:

(MutatePlainMergeTreeTask|MutateFromLogEntryTask|MergeTreeBackgroundExecutor).*(Cannot parse string .* as .*CANNOT_PARSE_TEXT|FUNCTION_THROW_IF_VALUE_IS_NON_ZERO)

This makes #108563 (literal throwIf entry) redundant, so I closed it in favor of this one.

@alexey-milovidov

Copy link
Copy Markdown
Member

Merged current master into the branch and re-fired CI (approved the gated run on 7e2400c78b6).

Merge was clean, no conflicts. The rebase base already carried the per-literal Cannot parse string 'x' as UInt64 entry, so master's subsequent "Remove strange trash (again)" work (SettingFieldMaxThreads::toString now renders auto(N) unquoted, plus the upgrade-check settings-history suppression of the pure quoted-vs-unquoted rendering difference) landed in a non-overlapping region. The net diff of this PR over master is exactly the approved class-based change:

  • the per-literal Cannot parse string … allowlist entries are removed,
  • the single error-CLASS regex is added to the secondary pipe,
  • master's auto(N) settings-history suppression is preserved untouched.

Validated the merged filter functionally against representative log lines: benign background-mutation errors with arbitrary literals ('x', 'a', fuzzer-style 'fuzz_QQ_7!') and the throwIf case all drop, while genuine bugs survive — including a CANNOT_READ_ALL_DATA raised on the same MutatePlainMergeTreeTask executor, confirming the match is scoped to the two benign error codes and does not over-suppress.

Resolved the one outstanding AI-review wording nit (already reworded in 8dbd81ec173).

One thing to flag for a quick glance: the FUNCTION_THROW_IF_VALUE_IS_NON_ZERO arm of the regex was added (11b8b6b3942) after the cc33023 approval, which only covered CANNOT_PARSE_TEXT. It is the same #39174 class on the same background-mutation executors (02597_column_update_tricky_expression_and_replication), so it fits the approved design, but it is new since the approval.

Comment thread tests/docker_scripts/upgrade_runner.sh Resolved
…utor name

The broad fixed-string `-e "MutateFromLogEntryTask"` entry in the primary
rg -Fav stage dropped every replicated-mutation <Error> line (any code)
before the class regex could constrain it, so unrelated replicated-mutation
regressions were hidden. The class regex already lists MutateFromLogEntryTask
alongside MutatePlainMergeTreeTask / MergeTreeBackgroundExecutor and only
suppresses the two benign ClickHouse#39174 codes (CANNOT_PARSE_TEXT,
FUNCTION_THROW_IF_VALUE_IS_NON_ZERO), which sit inline on the same log line as
the executor token. Removing the broad entry lets it scope the replicated path
too; any other code on those executors now reaches upgrade_error_messages.txt.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Status — head 1427e7fbfb1

0 behind master, MERGEABLE, 0 unresolved threads.

What changed since your 06-28 approval (heads-up — the approval predates these):

  • cc33023/rebase: replaced the per-literal Cannot parse string … allow-list with the error-class regex, and folded in the second benign Upgrade check fails if threre's invalid mutation #39174 class FUNCTION_THROW_IF_VALUE_IS_NON_ZERO (UPDATE … throwIf, e.g. 02597_column_update_tricky_expression_and_replication).
  • 1427e7fbfb1: removed the broad fixed-string -e "MutateFromLogEntryTask" entry from the primary rg -Fav stage. This was the AI review's blocking Major — the broad entry dropped every replicated-mutation <Error> line before the class regex could constrain it, hiding unrelated replicated-mutation regressions. The class regex already lists MutateFromLogEntryTask, so the replicated path is now scoped to the two benign codes only.

Validation (the focused filter check the AI asked for), run against the exact regex:

  • Dropped: CANNOT_PARSE_TEXT and FUNCTION_THROW_IF_VALUE_IS_NON_ZERO on each of MutatePlainMergeTreeTask / MutateFromLogEntryTask / MergeTreeBackgroundExecutor.
  • Survives → reaches upgrade_error_messages.txt: an unrelated LOGICAL_ERROR / MEMORY_LIMIT_EXCEEDED on those same mutation executors.

Source-confirmed that the executor token and the error code share one physical log line: MutatePlainMergeTreeTask logs the full exception at MutatePlainMergeTreeTask.cpp:155; MutateFromLogEntryTask logs via tryLogCurrentException(log, …) (ReplicatedMergeMutateTaskBase.cpp:87/96) with (MutateFromLogEntryTask) in the logger name.

Re-fired the gated CI run on this head. The diff is test-only (upgrade_runner.sh). Ready for a fresh look + merge once the Upgrade check is green.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — 1427e7f

Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

The PR target is green: Upgrade check (amd_release) = SUCCESS (12 OK) on this head. The class-based background-mutation filter (CANNOT_PARSE_TEXT + FUNCTION_THROW_IF_VALUE_IS_NON_ZERO on a mutation executor) works; the previously-leaked <Error> lines no longer trip the gate.

Check / test Reason Owner / fixing PR
Stress test (amd_tsan) / Hung check failed, possible deadlock found deadlock (chronic, 510 PRs / 239 master / 30d; not caused by an upgrade_runner.sh test-infra diff) #105905 (ours, open)
Stress test (arm_tsan) / Hung check failed, possible deadlock found deadlock (same chronic family) #105905 (ours, open)
Stress test (arm_ubsan) / UndefinedBehaviorSanitizer STID 4231-40cb (RemoteQueryExecutor.cpp:921, null Poco::Logger deref) trunk UBSan (4 PRs / 0 master / 30d; lazy remote source, unrelated to this diff) #108547 (ours, open)
CH Inc sync - CH Inc sync (private, not actionable)

Session id: cron:our-pr-ci-monitor:20260630-093000

…eck-04338-x-uint64-allowlist

# Conflicts:
#	tests/docker_scripts/upgrade_runner.sh
@groeneai

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Resolved a fresh conflict with master (head b1677eac5d5, MERGEABLE, upgrade_runner.sh only).

master had again added a per-literal entry (Cannot parse string 'fail' as Int8, for 01155_old_mutation_parts_to_do). Dropped it: the class regex already covers it (CANNOT_PARSE_TEXT on a background-mutation executor, any value/type). Its doc bullet is folded into the class comment as an example.

Kept master's two benign PostgreSQLConnectionPool / DatabasePostgreSQL::removeOutdatedTables filters (orthogonal to this change) and placed the class regex after them.

Re-ran the pipe simulation on the resolved script: the benign classes (incl. 'fail' as Int8 and fuzzer-generated literals/types) drop; a synthetic MutateFromLogEntryTask ... (SOME_OTHER_ERROR), CANNOT_READ_ALL_DATA, LOGICAL_ERROR, and a CANNOT_PARSE_TEXT from a non-mutation component all survive. No logic change vs the approved head.

Comment thread tests/docker_scripts/upgrade_runner.sh Resolved
MergeTreeBackgroundExecutor is a shared logger for all background merge and
mutate jobs (getLogger("MergeTreeBackgroundExecutor"), one name for the
merge_mutate/moves/fetch/common executors), and its routine() re-logs a
wrapped exception with only that shared name and no mutation-specific token.
Matching the two benign codes on that token alone therefore also suppressed a
genuine merge-path CANNOT_PARSE_TEXT / FUNCTION_THROW_IF_VALUE_IS_NON_ZERO,
hiding real merge regressions.

Narrow the match to also require the user-expression evaluation frame
(while executing 'FUNCTION ...). The intentionally-broken ClickHouse#39174 mutations
fail while evaluating a user _CAST or throwIf expression and always carry that
frame; merge-engine work (serialization, IO, checksums) never evaluates a user
FUNCTION expression, so a genuine merge-path failure with either code lacks the
frame and still reaches upgrade_error_messages.txt.

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

groeneai commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #108856 (throwIf) and #108835 (CANNOT_PARSE_TEXT mutation errors), both merged to master. Between them the Upgrade check now allowlists everything this PR targeted, including 04338's 'x' as UInt64 and the FUNCTION_THROW_IF_VALUE_IS_NON_ZERO class, and master's Upgrade check (amd_release) is clean (0 mutation-class leaks on master since the 21:05Z merge; the only post-merge leaks are stale-base PR runs that clear on rebase).

On the last bot comment about the shared MergeTreeBackgroundExecutor arm: agreed with your 22:59Z analysis that the code-anchored arm is required (the third wrapping line carries no task token) and can't be split merge-vs-mutate on the log line without a C++ logging change, which is out of scope here. Your merged approach covers the same cases, so no reason to keep this open. Thanks.

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 manual approve Manual approve required to run CI pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants