Skip to content

Fix race condition in KeeperClient test helper causing flaky test_rm_with_version - #97644

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-keeper-client-test-race-condition
Feb 23, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-keeper-client-test-race-condition

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Feb 22, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Fixed a race condition in KeeperClient.execute_query where epoll could process the stdout separator before reading stderr error data, causing exceptions to be silently swallowed
  • C++ side: flush cerr before writing the stdout separator in runInteractiveInputStream to ensure error data reaches the pipe buffer first
  • Python side: split the event loop into two passes — process stderr events first, then stdout — so errors are always collected before the separator check
  • Added try/finally cleanup and unique node paths to test_rm_with_version / test_rm_without_version

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97554&sha=3f86a6142c6920239c1b3adedfe82ccb5fcd6515&name_0=PR&name_1=Integration%20tests%20%28amd_binary%2C%204%2F5%29
#97554

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):

...

🤖 Generated with Claude Code

Version info

  • Merged into: 26.2.1.1058

@CLAassistant

CLAassistant commented Feb 22, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@clickhouse-gh

clickhouse-gh Bot commented Feb 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5bd35fe]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Feb 22, 2026
alexey-milovidov and others added 2 commits February 22, 2026 21:17
…t_rm_with_version`

The `execute_query` method in the Python test helper uses `epoll` to
read from both stdout and stderr of the keeper-client process. When
a command fails, the keeper-client writes the error to stderr and then
the separator to stdout. However, when both events arrive simultaneously
in `epoll.poll()`, the loop could process stdout first, find the
separator, and return successfully without ever reading the pending
stderr error data - causing the exception to be silently swallowed.

Fix both sides:
- C++ (`KeeperClient.cpp`): flush stderr before writing the stdout
  separator, ensuring error data is in the pipe buffer first.
- Python (`keeper_utils.py`): process stderr events before stdout
  events in the poll loop, so errors are always collected before
  checking the separator.

Also fix test cleanup: add `try/finally` with `drop_node_if_exists`
to `test_rm_with_version` and `test_rm_without_version`, and give
`test_rm_without_version` its own unique node path instead of
reusing `/test_rm_with_version_node`.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97554&sha=3f86a6142c6920239c1b3adedfe82ccb5fcd6515&name_0=PR&name_1=Integration%20tests%20%28amd_binary%2C%204%2F5%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-milovidov
alexey-milovidov force-pushed the fix-keeper-client-test-race-condition branch 3 times, most recently from 36b416c to 5bd35fe Compare February 22, 2026 22:43
@alexey-milovidov alexey-milovidov self-assigned this Feb 23, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Feb 23, 2026
Merged via the queue into master with commit 3aa3b14 Feb 23, 2026
144 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-keeper-client-test-race-condition branch February 23, 2026 03:57
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants