Skip to content

Make the stress-job test_results.tsv info codec reversible - #113857

Open
groeneai wants to merge 6 commits into
ClickHouse:masterfrom
groeneai:groeneai/tsv-info-codec-reversible
Open

groeneai wants to merge 6 commits into
ClickHouse:masterfrom
groeneai:groeneai/tsv-info-codec-reversible

Conversation

@groeneai

@groeneai groeneai commented Aug 7, 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 info column of test_results.tsv is the diagnostic text investigators read out of CIDB for
Stress test / Upgrade check failures. Its escape codec was not reversible, so that text was
silently wrong whenever the payload held a backslash.

Root cause: the escape character was never itself escaped. escape_tsv_info encoded \0 \t \r \n but not \, so an on-disk \n meant either an encoded LF or the payload's own two characters,
and the reader always chose the former. C:\new\table was shown as C:<LF>ew<TAB>able.

The shell producers broke on the same ambiguity: escaped() emits a literal four-character row
terminator, and its nine call sites appended it with echo -e, which collapses one escape level.
That destroyed every payload backslash and left \' leaking, on 500 rows over 30 days.

The change removes the second escape layer rather than decoding its symptoms. escape_tsv_info
escapes \ first; escaped() emits a single-level terminator and its nine call sites append with
printf "...%s\n"; the reader becomes a single-pass exact inverse of the Escaped rule, and stops
letting csv treat " as structural. A real TAB now survives, and \0 \b \f decode to real
bytes instead of staying two characters, which is safe because info is only displayed, never
re-parsed. The echo -e sites left untouched all write a constant info.

Validation. A three-test regression case over 15 payloads: on master 13 lose data and 6 rows
vanish entirely; after the fix, none. Encoding growth on a real 309 KB hung_check.log is +2
characters.

Those tests lived in ci/tests/test_stress_job.py, which #115650 removed along with the rest of
ci/tests/ and the CI Tests job that ran it. I took that deletion rather than relocating them,
which would re-add coverage that PR deliberately removed, so this ships the production change alone.


Workflow [PR]
Sync PR [sync-upstream/pr/113857]

groeneai and others added 4 commits August 7, 2026 08:25
The `info` column of `test_results.tsv` is the diagnostic text investigators
read out of CIDB for `Stress test` / `Upgrade check` failures. Its escape codec
was not injective, so that text was silently wrong whenever the payload held a
literal backslash or a single quote.

Root cause: the escape character was never itself escaped. `escape_tsv_info`
encoded `\0 \t \r \n` but not `\`, so an on-disk `\n` meant either an encoded LF
or the payload's own two characters, and the reader (three chained `str.replace`
calls) always resolved it to the former. A fuzzer query `SELECT '\n'` was shown
as a real line break, and `C:\new\table` as `C:<LF>ew<TAB>able`. A sequential
replace chain cannot be made injective at all, because it re-scans its own
output.

The shell producers broke on the same ambiguity from the other side. `escaped()`
emits ClickHouse's `Escaped` rule (which does escape `\`) with a literal
four-character row terminator, and the nine call sites appended the result with
`echo -e`, which collapses one escape level. That collapse was simultaneously
load-bearing, since it turned the four-character terminator into a real
separator and is the only reason multi-line rows read correctly, and
destructive, since it also destroyed every payload backslash, left the
two-character `\'` leaking into the displayed text, and turned an encoded `\t`
back into a real TAB that split the cell. Measured over 30 days, that is 500
rows across three sites carrying a visible `\'`, against a control site whose
`info` does not pass through `escaped()` at 0.

Rather than decode the symptom, remove the second escape layer so there is
nothing to disambiguate:

  - `escape_tsv_info` escapes `\` first, before the separators;
  - `escaped()` emits a single-level row terminator and its nine call sites
    append with `printf "...%s\n"`, so the escaped payload reaches disk
    verbatim. `printf` still interprets escapes in its format string, so `$OK`
    and `$FAIL` keep producing real tabs, while `%s` passes the payload
    through untouched;
  - the reader becomes `unescape_tsv_info`, a single-pass exact inverse of the
    `Escaped` rule over the alphabet that rule emits (`0 b f n r t \ '`), with
    an unrecognised `\X` kept verbatim rather than swallowed.

The reader also stops letting `csv` treat the double quote as structural. That
quote layer was a second undeclared codec on top of the one above: the double
quote is an ordinary character in the `Escaped` rule, so neither producer
escapes it, yet Python's `csv` reads a field-initial `"` as an opening quote.
`"quoted"` arrived as `quoted`, and an unterminated `"` made the reader consume
the two following result rows into that cell while reporting no malformed row
at all, so the `Corrupt test_results.tsv` surfacing could not fire and a real
`Hung check failed` row simply vanished from the report. `quoting=csv.QUOTE_NONE`
leaves the single escape layer as the only one.

After this there is one convention on disk, produced identically by both
producers, and one decoder that inverts it. A real TAB now survives where it
previously split the cell. A real NUL now survives too, and reaches
`Result.info` where the old chain could not produce one: that is safe because
`info` is only displayed and stored, never re-parsed, and none of the failure
patterns matched against it contains a backslash or a quote.

All nine `escaped`-family sites must convert together: a site left on `echo -e`
would keep producing the old ambiguous encoding that the new decoder misreads,
and the resulting failure would be a plausible-looking but wrong diagnostic
string. The 16 sites that keep `echo -e` do so deliberately; their `info` is
constant and they rely on the format-string escapes.

Two regression tests. The first round-trips through the real writer and the real
reader over the shapes that were lost, the shapes that already worked, the
double-quote shapes, and a real shell-produced on-disk cell; it also pins the
row swallow with a three-row fixture. It could not have been added before this
change, since it would have had to encode the lossy behaviour to pass. The
second is a static contract assertion over the two shell files, because no
Python assertion can observe the shell layer: reverting the row terminator, or
returning a single append site to `echo -e`, leaves every other assertion green
while corrupting every shell-produced row.

One transitional window is inherent to any codec change here: a file written by
an old image and read by a new job, or the reverse, decodes under the other
convention for one release. The blast radius is a diagnostic string, never a
verdict.
The shell contract test guarded `format_custom_row_after_delimiter` with a
loop over the regex matches, which executes zero times when the setting is
absent. It therefore pinned the setting's value but never its existence:
deleting the ` settings ...` clause from `escaped()`, or renaming the setting,
left every assertion in the file green.

That is not hypothetical. `format_custom_row_after_delimiter` defaults to a
real newline, so without the explicit two-character literal the helper emits
real line feeds, command substitution preserves them, and `printf` writes
several physical lines. Measured end-to-end against a real `clickhouse local`
with the append statement from `stress_tests.lib`, on a two-line payload:
with the setting the row occupies one physical line and both lines survive in
`info`; without it the row occupies two, `info` is truncated to the first, and
the remainder resurfaces as a malformed row. Half the diagnostic is lost.

Count the setting across both shell files and assert the total once. A
per-file assertion would be wrong: only `escaped()` sets it, so the count is
one in `stress_tests.lib` and zero in `upgrade_runner.sh`.

Co-Authored-By: Claude Opus 5 <[email protected]>
The shell contract test banned `echo -e` and required the substring `printf `,
but `printf` preserves the escaped payload only because that payload is a `%s`
argument. Two degradations keep the substring, keep the site count at nine and
keep the row terminator single level, while reintroducing the escape-collapsing
layer this branch removes: moving the substitution into the format string, and
using `%b` instead of `%s`.

Both were measured end to end against a real `clickhouse local`, sourcing
`escaped()` from the tree and executing the append statement verbatim. Each
turns a one-row, well-formed append into three physical lines with a malformed
row, truncates `info` to its first line, and destroys every payload backslash.
Neither reddened any committed assertion.

So require the shape rather than forbidding the old spelling: each site must
carry a double-quoted `printf` format, that format must not itself contain the
`escaped`/`head_escaped`/`trim_server_logs` substitution, and it must contain a
`%s` conversion. The order matters, because inlining the substitution also
removes `%s`; checking for the substitution first is what lets the two
degradations report distinct reasons.

The existing `echo -e` and `printf ` assertions stay, so a site returned to
`echo -e` still fails with its own message. The rule is clean on all nine
converted sites and flags all nine on the parent of this branch.
The shell-producer test asserts, per site, that the escaped output is not
appended with `echo -e`, that a double-quoted `printf` format is used, that
the substitution is not inside that format, and that the format carries a
`%s`. Three spellings satisfy every one of those and still corrupt the row,
measured with real bash against the payload shape `escaped()` actually emits:

  - dropping the quotes around the substitution splits the payload into words
    and writes five rows, each holding one word of what should be one `info`;
  - adding a `%b` beside the `%s` writes three physical lines, of which the
    parser keeps one with `info` truncated to the first line and reports one
    malformed;
  - an extra operand makes `printf` reuse the format and write two rows, the
    second carrying the operand as its `info`.

Nothing else in the repository would catch them: there is no shellcheck run,
`upgrade_runner.sh` disables SC2086 globally, and the two files already carry
four unquoted command substitutions, so the first spelling is native to them.

A rule over spellings cannot enumerate the corrupting forms, so assert the
outcome instead. The new test extracts each of the nine real append statements
from the scripts, joining backslash continuations and normalising a leading
`&&`/`||` and an enclosing subshell's trailing `)`, runs it under bash with the
three producer helpers stubbed to `printf '%s'` and the output redirected to a
temporary file, then requires exactly one physical line, one parsed row, no
malformed rows, and an `info` equal to the payload with its terminators decoded
to real line feeds. The site count is asserted so the scan cannot silently
cover fewer. The stub keeps this independent of a `clickhouse` binary, a server
and the network, which is verified rather than assumed.

The static test is kept byte for byte: it is what gives the terminator value, a
deleted `settings` clause and a renamed setting their own failure messages, and
the stub bypasses `escaped()` so the new test is blind to all three. The two are
complementary. `ci/tests/test_upgrade_runner_download_boundary.py` guards the
same shell file the same way and is the precedent followed here.
@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

Each finding below was adjudicated against the code, with the measurement that settled it.

# Severity Finding Verdict
❌ 1 major The shell contract test bans echo -e and checks for the substring printf , but does not require the escaped payload to be a %s argument. Two degradations keep both counts intact and reintroduce the escape-collapsing layer the change removes: moving the substitution into the format string, and using %b. Agreed, fixed. Measured end to end against a real clickhouse local with the append statement taken from stress_tests.lib: the shipped shape writes one physical line and keeps both payload backslashes, while either degradation writes three physical lines, destroys every payload backslash and truncates info to its first line. Both left every committed assertion green. The test now requires the %s-argument shape, and each degradation reddens with its own message.
❌ 2 major A rule over printf spellings cannot enumerate the corrupting forms. Three spellings satisfy every static assertion, including the %s-argument rule from finding 1, and still corrupt the row. Agreed, fixed. Measured with real bash against the payload shape escaped() emits: dropping the quotes around the substitution word-splits the payload into five rows; adding a %b beside the %s writes three physical lines; an extra operand makes printf reuse the format and write two. A second test now extracts each of the nine real append statements from the scripts and asserts the outcome under bash with a stubbed producer, so the contract is pinned by what lands in the file rather than by spelling.
⚠️ 3 nit The description attributed the \0 decode change to the shell producer. \b and \f are shell-only, but an escaped \0 reaches the decoder from the Python producer too: escape_tsv_info escapes NUL itself, and sanitize_test_result_line rewrites a raw on-disk NUL to \0 before the decoder runs. Agreed, corrected. The attribution is dropped and the disclosure kept.
⚠️ 4 nit The mutation summary said dropping \0/\b/\f reddens only the NUL row. It reddens two assertions: the payload dictionary on the real_nul row, and the shell-produced on-disk cell. Agreed, corrected.
⚠️ 5 nit The validation summary said "seven mutation arms". Under its own stated scope, an arm counts when it reverts a part of the change, and a tenth arm reverting the reader's quoting was added in the final round. Agreed, corrected to eight. Re-derived: eight arms revert a part of the change and eight are future-regression tripwires putting the tree into a state neither this change nor its base occupies. Every one of the five parts was confirmed absent at the base and present here, so each of the eight is a genuine revert.
💡 6 nit The recorded build id names a shared snapshot that is rebuilt nightly. Not done. Nothing published quotes a build id, and the change touches no compiled file, so the record is accurate for the round that measured it and rewriting it would only rot again.

Verified with no finding, independently of the author's evidence. The decoder's alphabet is
byte-identical to the eight escapes writeAnyEscapedString<'\''> emits, and round-tripping the
real writer through the real reader gives 0 failures over all 256 byte values in five placements,
over 22 adversarial literal sequences, and over eight shell-produced on-disk cells covering \b,
\f, \0 and \'; the decoder never raises over an exhaustive sweep of 4,096 backslash-bearing
strings. On the previous code 13 of the 15 pinned payloads lose data and 6 rows vanish entirely
into a preceding cell with no malformed row reported, which is the silent-loss shape. QUOTE_NONE
changes only the quote case and consumes no backslash, since it leaves escapechar unset. The
nine call sites are the complete set; the appenders that keep echo -e write a constant info,
counted as logical statements so that the one &&/|| chain whose other branch is a converted
site is not double-counted. Every mutation arm reddens the codec test or the shell tests but never
both, so no arm's failure is absorbed by a neighbour, and the new end-to-end arm is live at all
nine sites rather than vacuous at any. The transitional window was measured in both directions and
is confined to the info text: no arm loses a row, changes a status or reports a malformed row,
and the runner scripts cannot mismatch the parser at all, because the job mounts them from the
checkout rather than baking them into the image. The one genuine cross-version pair is the
previous-release binary that runs escaped() during the upgrade path, and the Escaped rule and
the row-terminator setting are identical on 26.7, 26.6, 26.5, 26.3 and 25.8.

One interaction with an open sibling, surfaced rather than left to CI. #113428 adds
test_small_log_is_embedded_whole_and_round_trips, whose last assertion is
assert [r.info for r in results] == [info.replace("\0", "\\0")] with the comment "NUL stays
escaped as \0". This change makes the decoder restore a real NUL, so that one assertion has to
be adjusted by whichever of the two merges second. Measured against the reader here: tab, CR and
LF agree in both expectations and NUL is the only differing class, so it is a single expected-value
edit on a deliberate, documented behaviour change rather than a defect in either branch. Nothing
else conflicts: a sweep of all 1,900 open pull requests found 13 touching any of these five files,
and scoring each full diff for the symbols this change touches leaves #113428 as the only hit,
against a positive control that scores the diff here on all seven patterns.

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, no server and no build. python3 .scratch/repro/py_roundtrip.py round-trips the real escape_tsv_info through the real read_test_results; the shell arm sources the tree's own stress_tests.lib and executes the append statement extracted verbatim from the Cannot start clickhouse-server site. On pristine master the new test's own corpus loses 13 of 15 payloads and 6 of its rows vanish entirely into a preceding cell; the recorded investigation corpus loses 5 of 12 and the real shell site 4 of 7. Zero randomness.
b Root cause explained? The escape character was never itself escaped. escape_tsv_info encoded \0 \t \r \n but not \, so an on-disk \n meant either an encoded LF or the payload's own two characters, and the reader (three chained str.replace calls) always resolved it to the former. On the shell side escaped() emits the Escaped rule with a literal four-character row terminator, and echo -e at the nine call sites collapsed one escape level, which was simultaneously load-bearing for the terminator and destructive for the payload.
c Fix matches root cause? Yes: the ambiguity is removed at the source rather than decoded at the display site. A reader-only fourth replace was measured to fix nothing (the writer emits no doubled form to collapse), and a \'-only decode was rejected during design because it repairs the visible symptom while leaving the literal-backslash class silently broken.
d Test intent preserved / new tests added? No existing assertion weakened; all 17 pre-existing tests in ci/tests/test_stress_job.py pass unchanged, including under csv.QUOTE_NONE. Three new focused test functions: the codec round trip (15 payloads, 5 of them controls, plus a three-row fixture pinning the quote swallow and one real on-disk shell cell); a static contract assertion over the two shell files, which is the only assertion that can observe the terminator's escape level; and an end-to-end arm that executes each of the 9 real append statements under bash with a stubbed producer and parses what lands in the file. No harness, no helper class.
e Both directions demonstrated? Yes. The new corpus goes from 13 losses and 6 swallowed rows to 0, the investigation corpus 5 to 0, the real shell site 4 to 0, all three new tests RED to PASS, the whole file from 3 failed / 17 passed to 20 / 20 PASS, and 50 consecutive repeats of the file all pass.
f Fix is general across code paths? Repo-wide search finds no other sequential-replace decoder of this codec in ci/, and the only other format_custom_row_after_delimiter users are stateless tests writing their own files (0 references to test_results.tsv in all 11). Fixed at the writer and format layer, not guarded at the display site. All 9 escaped-family call sites converted together; a new test asserts the caller count is still 9, that none remains on echo -e, that each site passes the escaped output as a %s argument rather than inside the printf format, and that the row terminator is single level. The append is also verified by outcome rather than by spelling: a second new test runs each of those 9 statements under bash with a stubbed producer and asserts the file holds exactly one row whose info is the payload verbatim, which is what catches the corrupting spellings a rule over printf forms cannot enumerate.
g Fix generalizes across inputs? 21-case matrix over every member of the Escaped alphabet (\b \f \n \r \t \0 \\ \') as both a real byte and a literal two-character sequence, plus doubled and triple backslash, quote, backslash-quote, empty payload, lone trailing backslash, an unknown \x escape, and an all-control mix: 0 losses after the fix, 5 before, so the matrix is not vacuous.
h Backward compatible? No setting, no serialization format, no SettingsChangesHistory surface; CI tooling only. One transitional window is inherent to any codec change here and is disclosed in the PR body: a file written by an old image and read by a new job decodes under the other convention for one release, blast radius a diagnostic string. Release branches were checked rather than assumed: 26.7, 26.6 and 26.5 carry all three functions, 26.3 lacks escape_tsv_info, 25.8 lacks both python functions, so no backport is proposed.
i Invariants and contracts preserved? The decoder is total: it never raises, a trailing lone \ emits itself, an unknown \X emits both characters rather than swallowing one, and an empty payload stays empty. Decode order relative to the existing pipeline was confirmed by reading it (split on LF, then sanitize_test_result_line, then decode), which is why a real NUL now round-trips where it was previously lost. Result.info consumers were checked rather than assumed: the integration job never calls read_test_results, and 0 of the 40 TEST_FAILURE_PATTERNS contain a backslash or a quote, so no decode change can alter a match.

Eight mutation arms each revert exactly one part of the fix and each reddens for its own reason.
Every codec-side arm reddens only the codec test, and every shell-side arm reddens only the shell
tests, so no arm's failure is absorbed by a neighbouring assertion. Reverting the
writer's backslash escape loses exactly the literal-backslash shapes; reverting the reader
additionally corrupts the shell rows; dropping ' from the decoder map reddens only the quote
shapes; dropping \0 reddens the NUL payload row and dropping \b/\f reddens the
shell-produced on-disk cell. Restoring the default csv quoting
makes a field-initial " consume the two following result rows, which the three-row fixture
catches by name. Reverting the row terminator, and reverting one append site to echo -e, both
leave every python assertion green and are caught only by the shell contract test, which is what
shows it observes the shell layer; against the real clickhouse local those two respectively
decode one escape level short and explode the row into three physical lines. Two further
degradations that keep printf but stop passing the payload as an argument, moving the
substitution into the format or using %b, are likewise caught only by that test and each names
its own reason; against the real clickhouse local both explode the row into three physical
lines and destroy every payload backslash. Three further spellings keep printf and a %s
argument yet still corrupt the row, and each is caught only by the end-to-end arm, naming the
site and the row count it observed: dropping the quotes around the substitution writes 5 rows
through word splitting, adding a %b beside the %s writes 3, and an extra operand makes
printf reuse the format and write 2.

ci/tests/ was compared as sets across the last fix round, 683 collected against 684, and the
failing set is byte-identical: 0 regressions. A whole-directory master arm is not the right
comparison, since reverting only the test file to its base version makes ci/tests/ collect 548
with 12 collection errors (the base file does not import the new symbols); the three new tests
were therefore run against pristine master through a shim, where all three fail. The 8
pre-existing failures are environmental and disjoint from this change (0 of them import anything
it touches): 5 assert a running clickhouse-server before doing anything, and 3 drive
clickhouse-test end to end, which needs the binary and a reachable server. Their count is
itself unstable for that reason, 7 in one arm and 8 in the other, which is why the comparison is
on the failing set and not on the count.

Session id: cron:clickhouse-impl-slot-40:20260807-151200

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

cc @maxknv @alexey-milovidov, could you review this? The info cell of test_results.tsv had a non-injective escape codec: escape_tsv_info never escaped the escape character, so an on-disk \n was ambiguous and the reader always read it as an encoded line feed, and escaped() emitted a row terminator at the payload's own escape level that its nine call sites then collapsed with echo -e. This escapes \ first, appends with printf "...%s\n", and makes the reader a single-pass exact inverse of the Escaped rule.

groeneai added a commit to groeneai/ClickHouse that referenced this pull request Aug 10, 2026
`Stress test (*)` and `Upgrade check (*)` never redirected the stress script's
output, so it reached only the job console and `test_results.tsv` recorded the
exit status alone. In the 30 days to 2026-08-09 all 152 `Test script failed` rows
carried a byte-identical ` script exit code: 1`, so the family could not be
triaged from the CI database; reading three of those job logs gave two unrelated
causes.

The script is now redirected to a capture outside `/test_output`, which is
uploaded wholesale, and mirrored to the console with `tail --pid`. It is not
piped: `prepare_for_hung_check` drops databases with a fire-and-forget
`Popen(..., shell=True)` that inherits the wrapper's stdout, and a pipe reader
waits for those clients long after the script exits, which timed the job out at
10800 s. The exit code is `$?` after `wait`, and the tail of the capture goes
into the `info` cell of the row the wrapper already emitted.

Those clients can also append after the script exits while the mirror ends with
it, so the wrapper waits for the capture to stop growing and then prints the
bytes the mirror missed. The wait is a bounded size poll rather than a wait on
the descriptor, since that is what deadlocked the pipe form, and the flush offset
is the mirror's own byte count because the file size afterwards can already
include unmirrored bytes.

`escaped()` pre-compensates its row terminator for `echo -e`, which collapses one
escape level, so a `printf '%s'` caller would get a backslash before every
decoded newline. `escaped_tail()` is its single-level sibling and `escaped()` is
untouched. The reader decodes `\t`, `\r` and `\n` only, so a byte the `Escaped`
rule encodes but it does not keeps a visible backslash; ClickHouse#113857 makes the codec
reversible. This fixes visibility, not the trigger.

Related: ClickHouse#113857

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai groeneai added the groeneai-origin-request PR origin: a maintainer pinged or directed groeneai label Aug 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bde3aee]

Summary: ❌

job_name test_name status info comment
Stress test (arm_msan) FAIL
Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-3e49) FAIL cidb
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb

AI Review

Summary

This PR makes the test_results.tsv info codec reversible by escaping backslashes in the Python writer, switching the shell appenders from echo -e to printf "...%s\n", and decoding info with a single-pass unescaper plus csv.QUOTE_NONE. The codec change itself is coherent in the current tree, but I do not think it should merge without restoring runnable regression coverage for this producer/consumer contract.

Findings

⚠️ Majors

  • [ci/jobs/stress_job.py:39] [dismissed by author -- https://github.com/Make the stress-job test_results.tsv info codec reversible #113857#discussion_r3889424982] This PR now lands a three-part codec change across escape_tsv_info, the shell producers in tests/docker_scripts/stress_tests.lib / tests/docker_scripts/upgrade_runner.sh, and read_test_results with no runnable in-tree regression test after ci/tests/test_stress_job.py was deleted. I still consider it real because this code fails open: one producer can drift and the job still parses the first TSV fields while silently corrupting only info, so a few stochastic Stress test runs are not proof that the contract is still wired correctly. Suggested fix: move the smallest deterministic round-trip and shell-append contract checks into a suite that still runs in CI, or add an equivalent lightweight self-check under a currently executed CI-test surface.
Final Verdict

Changes requested until the codec contract has runnable regression coverage again.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 27, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Aug 27, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 25dd035

Every failure below has an owner: a fixing PR (mine 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.

Check / test Reason Owner / fixing PR
Build profile diff RuntimeError: No master baseline with build profile data found - cannot compare (run_comparison). This head's merge base predates the fix: comparing the fix's merge commit 076ea56 against this head reports diverged, behind_by 5990, so the job ran without it. Every one of the 8 carriers of this signature in the last 30 hours is likewise a branch that does not contain it. #115007 (mine, merged 2026-08-17)
CH Inc sync - CH Inc sync (private, not actionable by me)

request-reviews-fork shows CANCELLED rather than a failure: the same job is SKIPPED in three
sibling runs on this head, so it is concurrency-group supersession between duplicate runs, and it
records no test result.

I am not merging master to pick the fix up on this branch. Mergeable Check is SUCCESS on this head
despite the red, so Build profile diff is non-gating here, and this PR carries manual approve, so a
push would spend a maintainer's manual workflow approval on a 5990-commit merge for a non-gating job.
The branch will pick #115007 up at the next master merge this PR needs anyway.

Session id: cron:our-pr-ci-monitor:20260827-233000

The only conflict was a modify/delete on ci/tests/test_stress_job.py:
this branch added three tests to it, and ClickHouse#115650 removed the whole
ci/tests suite together with the CI Tests job that ran it
(ci/jobs/ci_tests_job.py, JobConfigs.ci_tests, JobNames.CI_TESTS and the
pull_request.py entry). The file, the suite and the runner are all gone
on master, so the deletion is taken as-is rather than relocating the
tests to a new home: that would be re-adding coverage a maintainer had
just removed on the stated grounds that it pins CI-script internals
instead of observable behaviour.

The production fix is unchanged. Verified rather than assumed:
the added-line and removed-line sets of the four production files are
byte-identical before and after the merge (61 added, 22 removed), the
merged tree leaves zero echo -e sites that append a command-substituted
escaped payload, and master added no new site of that kind (its three
new echo -e sites in upgrade_runner.sh write a constant info). No
submodule pin moves relative to master.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Merged master. The only conflict was a modify/delete on ci/tests/test_stress_job.py: this branch added three tests to it, and #115650 removed the whole ci/tests/ suite together with the CI Tests job that ran it. I took the deletion rather than relocating the tests, so this is now the production change alone (4 files, +61/-22). Description updated to say so.

The fix itself is untouched, and I checked that rather than assuming it: the added-line and removed-line sets of the four production files are byte-identical before and after the merge (61 and 22), no echo -e site that appends a command-substituted escaped payload remains, master added none (the three echo -e lines it added carry a constant payload), and no submodule pin moves.

Comment thread ci/jobs/stress_job.py
}


def unescape_tsv_info(text: str) -> str:

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.

This PR changes a three-part codec contract: escape_tsv_info, the escaped()/head_escaped() shell producers, and read_test_results(). After ci/tests/test_stress_job.py was deleted, there is no executable coverage left in the tree that exercises that round trip end to end. That is risky here because regressions do not reliably fail closed: a drift in one producer can still leave the first TSV fields parseable and quietly corrupt only info, which is exactly the failure mode this patch is trying to eliminate. Please move at least the focused round-trip cases into a suite that still runs before merging the production change alone.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right about the mechanism: a drift in one producer corrupts only info while the first three fields stay parseable, so the job still passes. That asymmetry is what this change removes, and I am not claiming CI would fail closed on a regression of it.

The move itself is not available, which the description already records. On master 88f51c8dbe08 the directory holds 0 files and its runner went with it: ci_tests_job, JobConfigs.ci_tests, JobNames.CI_TESTS and the ci/workflows/pull_request.py entry all resolve to 0 references, against a control of stress_job at 10 files. That was #115650 (merged 2026-08-30T00:35:29Z) and #117138 (merged 2026-08-30T12:22:02Z), both by @ alexey-milovidov, on the stated grounds that the suite pinned "the internals of CI scripts rather than their observable behavior" and that AI bots had re-added the tests in previous attempts. No other in-tree home runs either: tests/ci/ has 0 test files, and the test_*.py files left under ci/ are job entrypoints or __main__ scripts with 0 def test_ and no invoker. Moving the same internals-pinning cases to a new path is that suite again under a different filename, so where such coverage should live is a maintainer's call rather than mine.

The round trip does run end to end in the job that owns it: ci/jobs/stress_job.py:198 runs stress_runner.sh, which sources stress_tests.lib, and the same job reads the file back at :239 through unescape_tsv_info. Nine Stress test jobs are in flight on this head.

Before taking the deletion I validated the codec out of tree: a 15-payload corpus (13 lost data before the change and none after, with 6 rows previously swallowed whole), a 21-case escape-alphabet matrix, and a five-arm mutation matrix in which reverting the writer, the reader, the escaped terminator, one echo -e append site, or the quote entry each reddens.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 6dadc6c

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.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) (job-level) not PR-caused (trunk tests/config/install.sh config guard) a fix task is created (investigating at full effort - fixing PR link to follow on this PR)
Upgrade check (amd_release) / Cannot start clickhouse-server not PR-caused: Code: 137 UNKNOWN_ELEMENT_IN_CONFIG, Unknown elements 'enable_silk_runtime', 'silk' found in config. install.sh symlinks tests/config/config.d/silk.xml unconditionally, so the previous-release server aborts before any test runs a fix task is created (same defect; fixing PR link to follow on this PR)
Upgrade check (amd_release) / Check failed not PR-caused: the job-level exit code 1 that follows the failed startup above, same event, same report a fix task is created (same defect; fixing PR link to follow on this PR)

Nothing here touches this PR's change. The evidence that it is a trunk condition rather than this
diff: the same signature fired on 26 distinct pull requests between 13:48:57Z and 16:08:07Z
today across unrelated branches, it has zero rows anywhere in CIDB in the preceding 14 days,
and install.sh is untouched by this PR. This PR was simply the first run past the boundary.

Session id: cron:our-pr-ci-monitor:20260830-160000

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Upgrade check (amd_release) lines in the ledger above: #117172, which version-gates the silk.xml test config so the previous-release server can start.

Not caused by this PR. The failure has hit every Upgrade check (amd_release) run since 13:48:57Z today, across more than 20 unrelated PRs, starting when v26.8.1.2041-lts became the previous release: install.sh symlinked config.d/silk.xml unconditionally, and a 26.8 server rejects enable_silk_runtime as an unknown config element.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - bde3aee

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link is
posted here when it opens.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Error message in clickhouse-server.log (see upgrade_error_messages.txt) Not introduced here, although this PR does touch the emitting script. The leaked line is Code: 16 ... Unexpected const virtual column: _table (NO_SUCH_COLUMN_IN_TABLE) from MutatePlainMergeTreeTask, an intentional background-mutation error produced by the stateless test 04510_mutation_query_plan_only_virtual_columns that the log scan does not yet allowlist. My hunks in tests/docker_scripts/upgrade_runner.sh only replace echo -e with printf so the info field survives round-tripping; the if [ -s upgrade_error_messages.txt ] gate and the whole exclusion chain above it are untouched, so the diff cannot make this row fire. #117218 (ours, open)
Stress test (arm_msan) / Logical error: Not-ready Set is passed as the second argument for function ... (STID 0250-3e49) Trunk defect that predates this branch: this PR changes CI harness scripts only and no source, so it cannot reach set building. Measured over the last 30 days in the CI database: 127 failing rows across 109 distinct pull requests, plus 7 rows on master. #102308 (external, open), tracked by #107619

Session id: cron:our-pr-ci-monitor:20260831-040000

@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Sep 4, 2026

This branch has not been deployed

No deployments
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 comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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