Skip to content

Fix data races between terminals in different threads of one process - #53

Closed
alexey-milovidov wants to merge 3 commits into
masterfrom
fix-races-concurrent-terminals
Closed

alexey-milovidov wants to merge 3 commits into
masterfrom
fix-races-concurrent-terminals

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

ClickHouse runs several embedded clients concurrently in the server (SSH and the Web Terminal), each with its own Replxx and Terminal. ThreadSanitizer in the Stress test found data races on the process-wide state:

  • _terminal_, written by enable_raw_mode and disable_raw_mode: it is atomic now;
  • the partial UTF-8 sequence in read_unicode_character: it is thread-local now;
  • the buffer returned by ansi_color: it is thread-local now.

The branch is based on 00cd994 (clickhouse/no-suspend-in-history-search), the commit ClickHouse master currently uses, so this PR also shows that commit.

Related: ClickHouse/ClickHouse#125517
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125517&sha=821f784ae6cfa635a3bf0e0d8ce486711e69cd53&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29

🤖 Generated with Claude Code

alexey-milovidov and others added 2 commits October 12, 2026 21:21
The incremental history search had its own handling of Ctrl-Z with
`raise( SIGSTOP )`, bypassing the key binding. When an application rebinds
Ctrl-Z to disable suspending (e.g. when the line editor runs inside a server
process serving a pseudoterminal), the search still stopped the process.

Now Ctrl-Z leaves the search and is passed to the main loop, like other
editing keys, so that it goes through the key binding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse runs several embedded clients concurrently in the server (SSH and the Web Terminal), each with its own `Replxx` and `Terminal`. ThreadSanitizer found data races on the process-wide state:
- `_terminal_`, written by `enable_raw_mode` and `disable_raw_mode`; it is atomic now;
- the partial UTF-8 sequence in `read_unicode_character`; it is thread-local now;
- the buffer returned by `ansi_color`; it is thread-local now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit to ClickHouse/ClickHouse that referenced this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant