Skip to content

Fix sporadic MySQL 8 container startup failure in integration tests - #96252

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-mysql8-rsa-key-generation-flaky
Feb 7, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-mysql8-rsa-key-generation-flaky

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

MySQL 8 sporadically fails during data directory initialization with "Could not generate RSA Private/Public key pair" in resource-constrained CI environments (ARM, container-in-container). These RSA keys are used for sha256_password / caching_sha2_password authentication plugins, which these tests don't use (mysql_native_password is the default).

The fix provides pre-generated RSA keys to the MySQL 8 container and disables auto-generation, eliminating the sporadic failure.

Failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96238&sha=856f7c28ba3cf10f393598a6f629af2af41de311&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%203%2F4%29
#96238

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Version info

  • Merged into: 26.2.1.359

MySQL 8 sporadically fails during data directory initialization with
"Could not generate RSA Private/Public key pair" in resource-constrained
CI environments (ARM, container-in-container). These RSA keys are used
for `sha256_password` / `caching_sha2_password` authentication plugins,
which these tests don't use (`mysql_native_password` is the default).

The fix provides pre-generated RSA keys to the MySQL 8 container and
disables auto-generation, eliminating the sporadic failure.

Failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96238&sha=856f7c28ba3cf10f393598a6f629af2af41de311&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%203%2F4%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [23d9de6]

Summary: ❌

job_name test_name status info comment
Stress test (amd_tsan) failure
Logical error: Block structure mismatch in A stream: different number of columns: (STID: 0993-2da1) FAIL cidb, issue
Stress test (arm_asan) failure
AddressSanitizer: stack-use-after-scope (STID: 0250-04e2) FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Feb 6, 2026
The cluster containers (mysql2, mysql3, mysql4) use `caching_sha2_password`
as the default auth plugin (they don't have
`--default_authentication_plugin='mysql_native_password'`). When RSA key
auto-generation was disabled without providing pre-generated keys, the
`caching_sha2_password` plugin could not authenticate, causing "Access
denied" for all connections.

Fix: mount the pre-generated RSA keys in the cluster containers and
configure the key paths, same as the mysql80 container.

Also revert unrelated changes that were accidentally included in the
initial commit (log_parser.py regression, .claude/ files, docs).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-milovidov
alexey-milovidov merged commit 3aa25fb into master Feb 7, 2026
127 of 129 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-mysql8-rsa-key-generation-flaky branch February 7, 2026 03:23
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 7, 2026
pull Bot pushed a commit to CrazyForks/ClickHouse that referenced this pull request Aug 3, 2026
Integration modules using with_mysql8=True sporadically fail their entire
module with "Exception: Cannot wait MySQL 8 container". Seen on 6 unrelated
PRs over the last 90 days (0 on master) across 4 job flavours, including
arm_binary and amd_llvm_coverage.

The MySQL 8 container's entrypoint calls mysql_ssl_rsa_setup under
"set -eo pipefail", inside docker_init_database_dir: after the datadir
bootstrap, but before docker_setup_db, which is the function that applies the
MYSQL_ROOT_HOST=% grant. A non-zero exit from that call therefore aborts the
entrypoint before the grant is created. "restart: always" on the compose
service then relaunches the container, and the second run finds an initialized
datadir, so DATABASE_ALREADY_EXISTS is set and the whole initialization block,
grant included, is skipped for good.

The server consequently comes up healthy while knowing only root@localhost,
and every connection from the docker gateway is rejected with MySQL error
1130. That error is issued before authentication and is permanent, so
wait_mysql8_to_start cannot recover from it and burns its full 180 s budget
before raising. In one collected report the waiter logged 342 such rejections
while the server had already been ready for 171 s. Because the fixture is
module-scoped, all 21 tests of the module were reported as failures from that
single event.

This finishes what ClickHouse#96252 started. That PR pre-generated all 11 cert and key
files and turned off server-side RSA generation, but left the entrypoint-side
generator in the image. The generator is dead work here: every SSL and RSA
path the server actually uses points at the bind-mounted /etc/mysql/certs,
and the eight .pem files this tool writes into the datadir are read by
nothing. The server log confirms it skips generation of its own accord.
Removing the executable makes the entrypoint's own "command -v" guard skip the
step, so initialization proceeds to the grant. rm -f keeps the layer
idempotent should a future base image ship without the binary.

Verified by injecting a deliberately failing mysql_ssl_rsa_setup, so both arms
run the same failing binary and only the fix differs. With it present:
RestartCount=1, a grant table holding only root@localhost, and 344
occurrences of error 1130 (the collected report shows 342), plus the same 16
initial connection-refused errors. With it removed: RestartCount=0, root@'%'
present, and the waiter succeeds. Six with_mysql8 modules show an identical
failure set before and after, including test_storage_mysql, which also
exercises the untouched official mysql:8.0 cluster nodes.

What makes that step fail in the wild is still unidentified: it did not fail
once in 480 local invocations under load. Since the step is dead work in this
configuration, removing it eliminates the failure mode regardless of the
trigger.

wait_mysql8_to_start now also reports the per-attempt errors it collects,
matching the three sibling MySQL waiters. It was the only one discarding them,
which is why the raised exception carried no diagnostics and this signature
went undiagnosed across six PRs. No fatal-fast on 1130 is added: that would
convert a future transient into a hard failure.
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.

2 participants