Repository navigation
Randomize the protocols in the Stress test - #125517
Conversation
Every `.sql` test of the Stress test now runs over a protocol chosen at random: native, native with TLS, HTTP, HTTPS, MySQL, PostgreSQL, gRPC, Arrow Flight, SSH or the Web Terminal, so that the randomized and fuzzed load reaches every protocol handler of the server, not only the native one. `clickhouse-test --protocols` picks the protocol of each `.sql` test from the list. The native protocols run with `clickhouse-client`; the others with the new `tests/protocol_client.py`, which splits the test into queries like `ClientBase` does, runs them one by one in one session with the same settings as the client would get, and stops at the first error that is not expected by a hint. SSH passes the whole test to the embedded client as the command of the channel, and the Web Terminal types the queries into the interactive embedded client through the WebSocket. The output of the protocols other than native does not match the references, so the option is only for runs that do not compare it. The test server config now enables the Arrow Flight port, `9090`. Closes: #125508 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… MySQL handshake Look for `FORMAT <name>` of an `INSERT` with inline data on the current line only, instead of matching the whole statement at every line break, which was quadratic in the size of a multi-line statement. Find the `INSERT` after the comments of the statement too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [a6a73f4] Summary: ✅ AI ReviewSummary#125517 randomizes the protocol used by stress-test SQL workloads. Reviewed head Findings
Missing context / blind spots
Final Verdict |
@groeneai fix the issue and send a PR. |
|
Acknowledged. I'm investigating the Arrow Flight DoGet failure on an empty result (the zero-chunk ChunkedArray built without a type); I'll follow up here with a PR (or my findings) shortly. |
|
Fix: #125534. |
|
Fix for the second Arrow Flight defect found by this PR (Stress test (arm_msan), |
|
Fix for the third defect found by this PR (Stress test (amd_debug), |
…o the web terminal losslessly and detect its errors
- Arrow Flight: `returns_result` looked only at the first word, so `WITH ... INSERT`
(e.g. `03565_union_all_nullptr.sql`) went to `DoGet`. It now looks past the `WITH`
clause for the first top-level `SELECT` or `INSERT`.
- Web terminal: the queries were collapsed into one line, which rewrote whitespace in
string literals and lost the record boundaries of inline `INSERT ... FORMAT` data.
They are now sent as a bracketed paste, verbatim and with their hint, so the
interactive embedded client splits them and applies `serverError` / `clientError`
hints itself. As the interactive client does not stop on an error, the output before
each prompt is checked for `Received exception` and for the hint mismatch messages of
`ClientBase::executeMultiQuery`, and the run stops with exit code 1 on the first one.
- The splitter now also recognizes inline data on the same line as the format name
(`INSERT INTO t FORMAT JSONEachRow {"x": 1}`), as `ClientBase` does; before, the data
swallowed the next query.
Checked against a local server: a sample of 40 stateless tests gives the same result
over `http` and `webterminal`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Status of the Stress test failures at c97500a. Each one is a server bug that the new protocols uncovered, not a bug of the runner:
The review comments are addressed in c1a332d: Arrow Flight sends |
…client.py`
A `-- { serverError ... }`, `-- { clientError ... }` or `-- { error ... }` hint
is now satisfied only by an error with one of its codes, as in `TestHint`:
the codes come from the protocol where it reports them (the HTTP
`X-ClickHouse-Exception-Code` header, the MySQL error code, the gRPC exception)
or from the `Code: N.` prefix of the message, and the names are resolved with
`system.errors`. The `error` hint was not recognized at all before.
There is no client side in these protocols, so a `clientError` hint is checked
against the server error, which has the same code (e.g. `SYNTAX_ERROR`). The
`ErrorResponse` of a failed PostgreSQL query has no ClickHouse code, so such an
error cannot be checked and is accepted.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Status of the Stress test failures at c1a332d. As before, these are server bugs that the new protocols uncovered:
The review comment about the test hints is addressed in 8dd652a: error codes are now compared. |
The native protocol logs a query only in `executeQuery`, from `formatForLogging`, which hides secret arguments. The Arrow Flight server additionally logged the raw request before running it: `FlightDescriptor::ToString` (whose `cmd` is the SQL text or a Flight SQL protobuf carrying it), the ticket (the SQL text when it is not a generated `~TICKET-` id), and `FlightInfo`, `PollInfo` and the `CancelFlightInfo` request, which embed that descriptor. gRPC's `getQueryDescription` logged the first 64 characters of the query. So a password in `CREATE USER ... IDENTIFIED BY`, a storage key in `s3` or `disk` arguments, or an `encrypt` key was written to the server log and `system.text_log` in plain text, even for a query that was then rejected. These lines now print only identifiers generated by the server (a prefix and a UUID, checked by form), the compiled-in name of a known Flight SQL command (never the client's type URL), a table path, or the size of anything else. gRPC prints the query size. Found by the protocol randomization of the stress test in ClickHouse#125517, where the test-only masking rule `Detect passwords in tests` aborted the server on the `DoPut is called for descriptor` line while `05340_custom_disk_error_hides_secrets` ran over Arrow Flight: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125517&sha=c1a332dfdd920abb5ceb3e4919fd6afe6eba0b72&name_0=PR&name_1=Stress%20test%20%28arm_debug%29 ClickHouse#125517 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Stress test now runs tests over SSH and the Web Terminal, so the server runs several embedded clients concurrently, and they raced on this static flag (set by `highlight`, read by the Enter key handler). Both accesses of one client happen in the thread running `Replxx::input`, so a thread-local flag is enough. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125517&sha=bdcfdd5963af20555d2d166e23d280c6b46f1f50&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 #125517 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ceptions and the web terminal prompt in `protocol_client.py` - HTTP and gRPC no longer pass the database and the settings with every request, where they overrode the session: they are set once with `USE` and `SET`, so the `SET` and `USE` of the test persist, as with `clickhouse-client`. - `split_queries` enters the inline data of `INSERT ... FORMAT <not Values>` right after the format name, like `ParserInsertQuery`, so semicolons in data on the same line (`00707_float_csv_delimiter`) no longer split it. - HTTP detects an exception appended to a response that has already started (the `__exception__` block tagged with `X-ClickHouse-Exception-Tag`), including when the server breaks the chunked response after it, and checks `X-ClickHouse-Exception-Code` regardless of the status. - The web terminal recognizes the prompt only after the `\e[?2004h` that replxx prints when it starts reading a new line, so `:) ` in an echoed query does not count as the prompt; errors printed after `exit` are checked too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
|
🕵 CH Inc sync: the Stress test ( |
…troyed its buffer `ClientBase::initOutputFormat` creates `output_format` over `std_out_wrapper` (or `out_file_buf`), and the format keeps a reference to that buffer. For a binary format on a terminal it then asks whether to output it anyway. In the web terminal, closing the session closes the PTY, the read of the answer fails with EIO, and the `catch` destroyed `out_file_buf` and `std_out_wrapper` while keeping `output_format`. `receiveResult` continues after the `LocalFormatError`, and `resetOutput` then finalized the format into the freed buffer: a heap use-after-free (ASan), use-of-uninitialized-value (MSan) and SIGSEGV (debug) in Stress tests since they run queries over the web terminal (ClickHouse#125517). Destroy the format first in that `catch`, before the buffers it writes into (the same order as `resetOutput`). A failure after the format was created now leaves the same state as a failure before it (ClickHouse#93298), and the next result packet creates the format again. The new test opens a web terminal session, runs a `RowBinary` query, waits for the question and closes the connection; the server must stay alive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`LocalConnection::finishQuery` resets `state`, and the next `receivePacket` reports `EndOfStream`. `ClientBase::processInsertQuery` calls `sendCancel` from its `catch (...)` for any exception, including one thrown after the query is over (an `INSERT` whose `SELECT` names `input` without reading it gets `EndOfStream` instead of a sample block; in the stress test of ClickHouse#125517 the web terminal closed at the end of an `INSERT` and the progress-line write to the dead PTY threw). `sendCancel` dereferenced the empty optional and libc++ hardening aborted: `clickhouse-local` itself, or the whole server for the embedded client of the web terminal and SSH (STID 2360-3d86). Every other `LocalConnection` entry point already treats an empty `state` as "no query in flight", and `TCPHandler` ignores a `Cancel` between queries. Make `sendCancel` do the same; the original exception is still reported. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the terminal of the client embedded into the server (SSH, Web Terminal) is gone, a failed write cancels `tty_buf` and reports the error, but the client keeps receiving progress packets, and `ProgressIndication::writeProgress` then writes into the canceled buffer, which is a `LOGICAL_ERROR` (`Cannot write to canceled buffer`) from `ClientBase::receiveEndOfQueryForInsert`. Skip rendering the progress indication and the progress table into a canceled buffer. Found by the Stress test with randomized protocols: ClickHouse#125517 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rver `ClientEmbeddedRunner::exit_code` was a plain `int`, written by the embedded client thread when `client.run()` returns and read by the SSH handler for `sendExitStatus` as soon as its loop ends. When the loop ends because the channel was closed or the server is shutting down while the client still runs, nothing orders the read before the write, which ThreadSanitizer reported in `Stress test (amd_tsan)` (STID 3766-25fc) once ClickHouse#125517 started running stress queries over SSH and killing clients. Make it a `std::atomic<int>`, like the neighbouring `waiting_for_query_input` and `prompts_count`. The values are unchanged: a reader that runs before the client finishes still gets the default 1. The new gtest reads the exit code right after starting a client that prints its version, with no synchronization in between, and then checks that the final code is 0 once the client has finished (which proves the write happened). Under TSan it aborts with the CI report pair without the fix and passes with it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DoPut, DoGet, GetSchema and executeSQLtoTables_impl (GetFlightInfo, DoAction) called BlockIO::onFinish from a SCOPE_EXIT, so on a successful call it ran in a destructor. onFinish allocates through memory-tracked containers (getProcessorsProfileLogInfo, printPipeline) and runs finish callbacks; on a normal scope exit the memory tracker is allowed to throw, so a MEMORY_LIMIT_EXCEEDED there left the destructor and called std::terminate. The stress test hit it through memory_tracker_fault_probability once it started sending queries over Arrow Flight (ClickHouse#125517): Stress test (arm_release), master a8e6d0b, STID 2618-2444. Call onFinish on the normal path after the work try/catch, as BlockIO::executeWithCallbacks and executeTrivialBlockIO do, and keep only onCancelOrConnectionLoss in the guard. The executors over the pipeline are locals of the try block, so they are still destroyed before onFinish releases the memory reservation their spill state points to. If onFinish throws, the guard cancels and resets the pipeline and releases the workload resources during unwinding, and the exception reaches tryRunAndLogIfError, which returns an error status to the client. The test loops all four calls in a Flight session with fault injection; the unfixed server aborts within a few dozen iterations. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With a `Pretty` format and `output_format_pretty_squash_consecutive_ms != 0`, `PrettyBlockOutputFormat` renders the squashed blocks from a background thread into the gRPC call's output buffer, under `IOutputFormat::writing_mutex`. The call thread read that buffer between the format calls without the mutex (`has_output` in `Call::generateOutput`, the copy and `restart()` in `Call::sendResult` for streaming calls), and finalized it on the exception path while the writer could still render a pending chunk (TSan STID 2046-35c1 in `Stress test (amd_tsan)`, where ClickHouse#125517 runs `.sql` tests over gRPC). - `IOutputFormat::lockWriting()` exposes the writing lock to the owner of the output buffer. - `Call::generateOutput` no longer reads the buffer: `has_output` only duplicated the "nothing to send" check of `sendResult`. - `Call::sendResult` holds the lock while it copies a non-final message. - `Call::onException` destroys the format (joining its writer) before the buffer is finalized. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflict in ArrowFlightServer.cpp: 26.10 does not have #125534 (the `block.empty()` check in `DoGet`), so that check is left out and only #129193's lines are kept. Leave out 05497_arrowflight_exception_on_query_finish: 26.10 has no Arrow Flight port in the stateless test config (#125517 is master-only), so the test cannot connect there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts in ArrowFlightServer.cpp: 26.9 does not have #115250, #125534 and #125553, which changed the same lines (conversion settings, the `block.empty()` check in `DoGet`, `removeSpecialColumnRepresentations`), so their changes are left out and only #129193's lines are kept. Leave out 05497_arrowflight_exception_on_query_finish: 26.9 has no Arrow Flight port in the stateless test config (#125517 is master-only), so the test cannot connect there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflicts in ArrowFlightServer.cpp: 26.8 does not have #115250, #125534 and #125553, which changed the same lines (conversion settings, the `block.empty()` check in `DoGet`, `removeSpecialColumnRepresentations`), so their changes are left out and only #129193's lines are kept. Leave out 05497_arrowflight_exception_on_query_finish: 26.8 has no Arrow Flight port in the stateless test config (#125517 is master-only), so the test cannot connect there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #125508
Every
.sqltest of the Stress test now runs over a protocol chosen at random from: native, native with TLS, HTTP, HTTPS, MySQL, PostgreSQL, gRPC, Arrow Flight, SSH and the Web Terminal. The randomized and fuzzed load (random settings, the server-side AST fuzzer, the random disruptor) now reaches every protocol handler, not only the native one.clickhouse-test --protocols a,b,...picks the protocol of each.sqltest at random from the list. Before running, it checks that the server listens on the port of each listed protocol. Forssh, it creates a key-authenticated userclickhouse_test_ssh. Without the option nothing changes.clickhouse-client, as before; fornative_tlsthe client uses--secureand the secure port.tests/protocol_client.py. It splits the test into queries the wayClientBasedoes (string literals, comments, heredocs, inlineINSERT ... FORMATdata up to an empty line). It runs them one by one in one session (HTTPsession_id, gRPC session, Arrow Flight session header, a single MySQL/PostgreSQL connection). It passes the same settingsclickhouse-clientwould get (random settings,--client-option, tag overrides,log_comment) withSETat the start of the session, so theSETandUSEof the test persist; the query parameters go natively over HTTP. It stops at the first error aserverError/clientErrorhint does not expect. MySQL and PostgreSQL use minimal wire clients written for it. gRPC uses the stubs fromutils/grpc-client/pb2, Arrow Flight usespyarrow.flight; both are already in the image.argvelement./webterminal, authenticates, and pastes the queries one by one into the interactive embedded client (as a bracketed paste, verbatim and with their hints), waiting for the prompt after each one. The embedded client applies the hints; the runner stops at the firstReceived exceptionor hint mismatch message it prints.protocol_client.pyprocesses, so every protocol handler sees clients disconnect mid-query.9090(tests/config/config.d/arrowflight.xml). It is removed from the replicas of the replicated-database setup, likessh.xml.replxx_last_is_delimiterofReplxxLineReader(found by the Stress test with TSan). It is now thread-local. The same holds for the process-wide state insidereplxx(_terminal_, the UTF-8 state ofread_unicode_character, the buffer ofansi_color): Fix data races between terminals in different threads of one process replxx#53, and the submodule is updated.I tested it locally against a server with all ports enabled: about 500 tests across all ten protocols with random settings and
--client-option. No runner errors came up, andsystem.query_logshowed every interface (TCPwith and without TLS,HTTP,MySQL,PostgreSQL,gRPC,ArrowFlight, andLocalfor the embedded client behind SSH and the Web Terminal).It already found one issue: over Arrow Flight,
DoGetof a query with an empty result (e.g.select number from system.numbers limit 0) fails withstd::exception. Code: 1001 ... chunked_array.cc:54: Check failed: (chunks_.size()) > (0). TheChunkedArrayis built from zero chunks without a type. It is an exception, not a crash, so it does not fail the Stress test.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The Stress test runs every
.sqltest over a random protocol: native, native with TLS, HTTP, HTTPS, MySQL, PostgreSQL, gRPC, Arrow Flight, SSH or the Web Terminal.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125517]
Version info
26.11.1.796-master(included in26.11and later)