Skip to content

Do not symbolize stack traces in two native-protocol tests that discard them - #121512

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:native-protocol-tests-no-text-stack-trace
Sep 23, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:native-protocol-tests-no-text-stack-trace

Conversation

@groeneai

@groeneai groeneai commented Sep 22, 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):

Two raw-socket native-protocol tests now ask the server not to build a text stack trace they immediately discard.

Description

02010_lc_native and 04616_replicated_serialization_oob_index_native_protocol speak the native TCP
protocol by hand and assert on the exception the server returns for a deliberately malformed block:
three of 02010's four exchanges, and all five of 04616's.

Detecting the malformation is trivial, but before answering the server materializes a text stack trace
that readException reads and throws away; neither .reference contains a trace. On
amd_llvm_coverage those symbol lookups cost 9.2 to 16.1 s per exchange against the
s.settimeout(30) hang guard: across 34 public jobs, 102 of 136 exchanges exceed 10 s, worst 16.11 s,
a 1.86x margin. In Stateless tests (amd_llvm_coverage, 1/3) on master
07f2c401,
02010's three exception exchanges take 11.59, 11.83 and 12.11 s of the 37.3 s that job records for the
whole test, while its one exchange expecting no exception takes 0.09 s: the cost is the trace, not the
insert.

Each test now sends calculate_text_stack_trace = 0 in the protocol's per-query settings field, one
site per file. It has to travel there, not in an inline SETTINGS clause: TCPHandler snapshots this
flag in extractConnectionSettingsFromContext, before executeQuery applies an inline clause, so such
a clause reaches the logging path but not the one answering the client. Every settimeout(30) is
untouched: the guard stays, with far more margin than the work that remains. Both tests assert on the
exception code and message, which do not change, so a regression still fails visibly, and
00921_datetime64_compatibility_long.sh already makes the same trade.

This signature has never failed publicly, 0 occurrences in 365 days: the claim is pointless work on
every run and a thin margin, not frequency. Deriving the deadline from CLICKHOUSE_TEST_TIMEOUT
instead would widen tolerance for a cost nobody consumes. 02010's valid-insert exchange involves no
trace, so this does not help it.

No related open issue found.


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

Version info

  • Merged into: 26.10.1.477-master (included in 26.10 and later)

…rd them

02010_lc_native and 04616_replicated_serialization_oob_index_native_protocol
speak the native TCP protocol by hand and send deliberately malformed blocks to
assert on the exception the server returns. Three of 02010's four exchanges and
all five of 04616's wait for such a rejection.

Detecting the malformation is trivial, but before the server can answer it
materializes a 21-frame symbolized text stack trace, and each test's
readException reads that field and throws it away. Neither .reference contains a
trace. On amd_llvm_coverage the symbol lookups cost 9.2 to 16.1 s per exchange,
against the s.settimeout(30) these tests use as a hang guard: across 34 public
jobs, 102 of 136 exchanges exceed 10 s and the worst is 16.11 s, a 1.86x margin.
The one 02010 exchange that expects no exception takes 0.09 to 0.15 s on the same
jobs, so the cost is the trace and not the insert.

Each test now sends calculate_text_stack_trace = 0 in the per-query settings
field of the protocol, one site per file, in the name/is_important/value format
02750_settings_alias_tcp_protocol.python uses at the same revision. It has to
travel there rather than in an inline SETTINGS clause: TCPHandler snapshots
send_exception_with_stack_trace in extractConnectionSettingsFromContext before it
calls executeQuery, which is where an inline clause would be applied. That
snapshot feeds the four sendException call sites and the LOG_INFO/LOG_ERROR pair,
while executeQuery separately gates getExceptionStackTraceString on the same
setting, and Exception::getStackTraceString() re-materializes on each call. So
disabling only the executeQuery path would move the cost to sendException while
the server log lost its Stack trace marker. is_important = 1 makes a future
rename of the setting a loud failure rather than a silent revert to symbolizing.

Every settimeout(30) is left untouched, so the hang guard still bounds an
unresponsive server. Verified: both tests raise TimeoutError in readStrict at
30 s against a listener that accepts and never answers; the wire trace measures
0 bytes fixed against 3886 to 4560 bytes on base; the Stack trace log marker
disappears from all eight exception exchanges; stdout stays byte-identical to
.reference; and 50 of 50 randomized runs pass for each test.

Deriving the socket deadline from CLICKHOUSE_TEST_TIMEOUT was considered and
rejected: it widens the tolerance for a cost nobody consumes instead of removing
it.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Sep 22, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; two full passes over this tree, 3 findings).

# Sev Finding Verdict Evidence / action
1 ⚠️ Neither test asserts that the returned stack-trace field is empty, so reverting or ignoring the new setting still passes DISAGREE The setting cannot be ignored silently: a misencoded settings field moves the terminator and the next read fails, and an unknown or renamed setting throws in BaseSettingsHelpers::throwSettingNotFound precisely because the triple carries is_important = 1. The one silent mode left, the server ceasing to honour calculate_text_stack_trace, is 02796_calculate_text_stack_trace.sql's contract rather than these tests'. An in-file assertion does not survive deliberate removal of the same four lines either, and it would make a LowCardinality deserialization test and an out-of-bounds regression test fail on the server's stack-trace policy. Measured instead: the wire trace is 3886 to 4560 bytes on base and 0 on all eight exchanges after the change, twice over, plus 48 of 48 under randomized settings. I will add the assertion if a maintainer prefers it.
2 ⚠️ The linked report does not substantiate the 9.2 to 16.1 s per-exchange baseline, since it records 2.66 s and 5.03 s for these tests DISAGREE Those two durations belong to Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel). The measurement is from Stateless tests (amd_llvm_coverage, 1/3), where the same commit records 37.34 s for 02010_lc_native and the three measured exchange windows account for 35.5 s of it; on the second master commit that job records 35.4 s against 9.18, 10.93 and 13.55 s. The description now names the job, so the arithmetic is checkable.
3 💡 The added comments leave TCPHandler, calculate_text_stack_trace, readException, executeQuery and SETTINGS without inline code formatting AGREE, not in this revision AGENTS.md requires literal class, function and SQL names in comments to be wrapped in inline code blocks, so the finding is right. It is not fixed here: the step that publishes this branch is allowed to rewrite comments only under src/, programs/ and base/, and never to touch a test file. I will wrap them on request.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

The other raw-socket .python tests are left alone deliberately: their worst measured exchange is 1.9 s in 05061_query_log_interface_enum_unknown and 0.0 s in 02750_settings_alias_tcp_protocol, and the 5 s deadline in 04092_tcp_settings_parse_error_closes_connection.py is semantic, since a TimeoutError there is swallowed as a pass.

Session id: cron:clickhouse-review-slot-10:20260922-070106

@clickhouse-gh clickhouse-gh Bot closed this Sep 22, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 22, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e803438]

Summary: ✅


AI Review

Summary

This PR updates two raw native-protocol stateless tests to send calculate_text_stack_trace = 0 in the query packet, so expected exception paths stop paying to symbolize a text stack trace that the test client immediately discards. I reviewed the current diff, the surrounding test code, the relevant TCPHandler settings flow, and the existing PR discussion; I did not find a correctness, compatibility, or coverage issue that warrants an inline review comment.

Final Verdict

✅ No blocking findings.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Sep 22, 2026
@groeneai
groeneai requested a review from Avogar September 22, 2026 07:49
@PedroTadim PedroTadim self-assigned this Sep 22, 2026
@PedroTadim

Copy link
Copy Markdown
Member

@Avogar you can give a look. The PR is very small

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 22, 2026
@alexey-milovidov alexey-milovidov self-assigned this Sep 22, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 22, 2026
Merged via the queue into ClickHouse:master with commit ebb00cc Sep 23, 2026
176 of 349 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 23, 2026
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-testing Test content only (no production code). groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet 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.

4 participants