Repository navigation
Do not share line editor state between concurrent embedded client sessions - #125510
Conversation
…sions Client sessions embedded into the server (the web terminal and SSH) run concurrently in one process, but the line editor kept some of its state in process-wide variables: - `replxx_last_is_delimiter` in `ReplxxLineReader.cpp`, which decides whether Enter commits the query in multiline mode. It is now a member of `ReplxxLineReader`, reported by the highlighter callback. - In replxx: the receiver of `SIGWINCH`, the partially read UTF-8 sequence in `read_unicode_character` (concurrent multi-byte input could corrupt each other, and a race allowed a one-byte out-of-bounds write), the modifiers of the escape sequence being parsed, and the buffer of `ansi_color`. An embedded client no longer installs the `SIGWINCH` handler in the server process: its terminal size is updated by the server, and replxx queries it on every refresh. Related: ClickHouse/clickhouse-private#80922 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [cd7aad2] Summary: ✅
AI ReviewSummaryPR #125510 moves delimiter tracking from thread-local storage into each Missing context / blind spots
Final VerdictStatus: ✅ Approve. No new inline findings. |
`master` of `replxx` now contains the fix of the shared terminal state. The new commit merges it with the history recall changes used by ClickHouse and fixes Ctrl-V blocking after the esc delay support from `master`. Related: ClickHouse/replxx#44 Related: ClickHouse/replxx#46 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 units17 translation units recompiled, 81 s compile time in total, 17 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
azat
left a comment
There was a problem hiding this comment.
I think that the changes in replxx is not enough - https://github.com/ClickHouse/replxx/pull/44/files#r4258134618
The previous `replxx` commit had a regression from the esc delay support in `replxx` `master`: Meta with escape sequences (e.g. Meta+Up) was not recognized, and `04909_client_hints_history_navigation` (`meta_up_recall_no_hints`) failed in every stateless test job: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125510&sha=33773832dc78e5a5e773171f8b489ca21d9bd77a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 #125510 The new commit is current `replxx` `master` (which also has the UTF-8 decoder state kept per `Terminal` from ClickHouse/replxx#47) plus the fix. Related: ClickHouse/replxx#48 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The same tree as the previous `replxx` commit, now merged into `replxx` `master` via ClickHouse/replxx#48. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dth on refresh Address review: `read_unicode_character` decoded an uninitialized byte when `poll` reported only `POLLHUP`/`POLLERR`/`POLLNVAL`, and the embedded client, which does not install the `SIGWINCH` handler, kept rendering against the startup width after a resize. Both are fixed in ClickHouse/replxx#49. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: - `contrib/replxx`: kept the pointer of this PR (`33a566d`). It already contains the `Ctrl-Z` fix in incremental history search that `master` points to (`00cd994`, merged into `replxx` `master` as `91703bf`), together with the Meta+Up fix, the thread-local decoder state, and the hangup and terminal width fixes this PR needs. - `src/Client/ReplxxLineReader.cpp`: kept the comment of this PR about `SIGWINCH`, which matches re-reading the terminal width on every refresh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #125510 to 26.3: Do not share line editor state between concurrent embedded client sessions
…urrent embedded client sessions
Cherry pick #125510 to 26.8: Do not share line editor state between concurrent embedded client sessions
…urrent embedded client sessions
Cherry pick #125510 to 26.9: Do not share line editor state between concurrent embedded client sessions
…urrent embedded client sessions
Cherry pick #125510 to 26.10: Do not share line editor state between concurrent embedded client sessions
…current embedded client sessions
Backport #125510 to 26.10: Do not share line editor state between concurrent embedded client sessions
Backport #125510 to 26.9: Do not share line editor state between concurrent embedded client sessions
Backport #125510 to 26.8: Do not share line editor state between concurrent embedded client sessions
Backport #125510 to 26.3: Do not share line editor state between concurrent embedded client sessions
…urrent embedded client sessions
…urrent embedded client sessions
`ProgressIndication::writeProgress` kept the frame of the spinning indicator in a function-local `static`, which is shared by all clients in the process. Concurrent sessions of the web terminal (embedded clients) increment it from several threads, which TSan reports as a data race. It fails every `Stress test (amd_tsan)` run since `05445_webterminal_concurrent_sessions_input` came with the backport of #125510. Backport of 3329e92 from #125514 (only this commit; the rest of the PR is a feature). https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=26.10&sha=da23b6505a74b35f9ef57cb2a3a26665db3fd763&name_0=ReleaseBranchCI #125514 (cherry picked from commit 3329e92) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…urrent embedded client sessions
`ProgressIndication::writeProgress` kept the frame of the spinning indicator in a function-local `static`, which is shared by all clients in the process. Concurrent sessions of the web terminal (embedded clients) increment it from several threads, which TSan reports as a data race. It fails every `Stress test (amd_tsan)` run since `05445_webterminal_concurrent_sessions_input` came with the backport of #125510. Backport of 3329e92 from #125514 (only this commit; the rest of the PR is a feature). https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=26.10&sha=da23b6505a74b35f9ef57cb2a3a26665db3fd763&name_0=ReleaseBranchCI #125514 (cherry picked from commit 3329e92) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…current embedded client sessions
`ProgressIndication::writeProgress` kept the frame of the spinning indicator in a function-local `static`, which is shared by all clients in the process. Concurrent sessions of the web terminal (embedded clients) increment it from several threads, which TSan reports as a data race. It fails every `Stress test (amd_tsan)` run since `05445_webterminal_concurrent_sessions_input` came with the backport of #125510. Backport of 3329e92 from #125514 (only this commit; the rest of the PR is a feature). https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=26.10&sha=da23b6505a74b35f9ef57cb2a3a26665db3fd763&name_0=ReleaseBranchCI #125514 (cherry picked from commit 3329e92) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Client sessions embedded into the server (
/webterminaland SSH) run concurrently in one process, so the line editor must not keep per-session state in process-wide variables.Most of the original fix of this PR has landed in
masterthrough other pull requests in the meantime:replxxchanges (per-terminalSIGWINCHregistration, per-thread/per-terminal UTF-8 decoder state, escape-sequence modifiers,ansi_colorbuffer, hangup handling, and re-reading the terminal width on every refresh):contrib/replxxinmasteralready points to ClickHouse/replxx@191e04e (Fix out-of-bounds accesses in the replxx line editor #126120).SIGWINCHhandler in the embedded mode, and makingreplxx_last_is_delimiterthread-local (Apply the session limits of other interfaces to the web terminal #125514).What remains in this PR:
replxx_last_is_delimiter(which decides whether Enter commits the query in multiline mode) is replaced by thelast_is_delimitermember ofReplxxLineReader, reported by the highlighter callback. The state belongs to the session, not to whichever thread happens to run it, andReplxxLineReader::setLastIsDelimiteris removed.05445_webterminal_concurrent_sessions_inputthat opens two/webterminalsessions and sends their queries byte by byte, interleaved, with multi-byte UTF-8 characters split across frames, and checks that each session decodes its own query. It passes onmastertoo (the fixes are already there), and serves as a regression test.Related: #126120
Related: #125514
Related: ClickHouse/replxx#44
Related: ClickHouse/replxx#49
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Keep the "last token is a delimiter" state of the line editor per session instead of per thread.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125510]
Version info
26.11.1.798-master(included in26.11and later)26.10.3.14,26.9.26.24,26.8.35.21,26.3.61.15