Skip to content

Cherry pick #125510 to 26.3: Do not share line editor state between concurrent embedded client sessions - #127884

Merged
robot-ch-test-poll2 merged 18 commits into
backport/26.3/125510from
cherrypick/26.3/125510
Oct 27, 2026
Merged

robot-ch-test-poll2 merged 18 commits into
backport/26.3/125510from
cherrypick/26.3/125510

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #125510

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 17 commits October 12, 2026 21:27
…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]>
`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]>
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]>
ClickHouse/replxx#49 is merged into `replxx` `master`.
The merge commit also contains the `Ctrl-Z` fix for the incremental history
search that `master` points to (ClickHouse/replxx#45) and the history search
cursor fix (ClickHouse/replxx#50).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict in `src/Client/ReplxxLineReader.cpp`: master made `replxx_last_is_delimiter`
thread-local; this PR replaces it with the `last_is_delimiter` member reported by
the highlighter callback, so the thread-local variable and `setLastIsDelimiter` are dropped.
Two web terminal sessions receive their queries byte by byte, interleaved, with
multi-byte UTF-8 characters split between the sessions, and each session must
decode its own query.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-state

Do not share line editor state between concurrent embedded client sessions
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Oct 26, 2026
…e conflicts

Adapt the change to the 26.3 API: `highlight` there has no `rainbow_parentheses`
and `lexer_fallback` parameters, so only the new `last_is_delimiter` parameter is
added, and the Enter handler keeps its 26.3 condition with the global flag replaced
by the `ReplxxLineReader` member. The `SIGWINCH` comment is kept as in 26.3.

The test `05445_webterminal_concurrent_sessions_input` is dropped: 26.3 has no
`/webterminal` endpoint. The fix still matters there for concurrent SSH sessions
embedded into the server, which shared the non-thread-local global flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-ch-test-poll2
robot-ch-test-poll2 merged commit d1a8b41 into backport/26.3/125510 Oct 27, 2026
1 check passed
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/26.3/125510 branch October 27, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants