Repository navigation
test/docker: bake mysql+postgres data dirs so cold start is ~2-3s, stop healthcheck wedge - #33822
Conversation
On alpine CI hosts, mysql:8.4 first-boot init (timezone load + temp server restart) regularly takes 62-65s when three mysqld containers are starting in parallel. That overshoots start_period: 60s, at which point the engine switches the probe cadence from start_interval: 1s to interval: 1h, so the container sits at 'health: starting' for an hour even though mysqld is accepting connections two seconds later. Every subsequent compose up --wait --wait-timeout 60 then times out, and each mysql-backed test file burns 60s per retry before failing. In a sample of the 30 most recent failed alpine test-bun jobs, 20 were this exact 'application not healthy after 1m0s' error (x64, x64-baseline and aarch64); 0 of 20 debian/ubuntu failures were. Drop interval to 5s on every service that had it at 1h, so overshooting start_period is a one-probe delay rather than an hour-long wedge. Raise the mysql services' start_period to 180s, the up --wait-timeout to 180, and the container beforeAll hook timeouts to 240s to match.
|
Warning Review limit reached
Next review available in: 31 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughThis PR adds two new MySQL Docker test images (plain and native-password) with pre-initialized datadirs, updates the mysql-tls Dockerfile similarly, rewires docker-compose.yml to build these local images and reduces healthcheck intervals from 1h to 5s, and increases various wait-timeout and beforeAll timeout values (60s→180s, 120_000→240_000ms) across compose helpers and dependent tests. ChangesMySQL Test Container and Docker Compose Timing Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
Updated 8:07 PM PT - Jul 9th, 2026
❌ @robobun, your commit b6e37ee has 3 failures in
🧪 To try this PR locally: bunx bun-pr 33822That installs a local version of the PR into your bun-33822 --bun |
~39s of the ~62s mysql first-boot init is mysql_tzinfo_to_sql loading /usr/share/zoneinfo into mysql.time_zone_*; ~15s is mysqld --initialize-insecure; the rest is the entrypoint's temp-server bounce. No bun test uses MySQL's named-timezone tables (the datetime-roundtrip test only varies the process TZ, not the session time_zone). Move all of that to docker build time: new Dockerfile.mysql-plain and Dockerfile.mysql-native-password (and the existing mysql-tls Dockerfile) run the stock entrypoint once with MYSQL_INITDB_SKIP_TZINFO=1 against a sibling datadir (the base image's VOLUME /var/lib/mysql discards build-time writes there), wait for TCP ready, shut down, and set CMD to point mysqld at the baked dir. At container start the entrypoint sees the datadir is populated and execs mysqld directly. tmpfs is dropped since the baked dir lives on the container's CoW layer; a fresh container is still a fresh database.
There was a problem hiding this comment.
Both earlier nits are addressed and I found nothing further, but this reworks how the mysql test containers are built (baked datadir, dropped tmpfs) and the author notes it couldn't be verified locally — worth a human confirming the alpine lanes in #70904 are green before merging.
Extended reasoning...
Overview
Test-infrastructure-only change addressing a recurring alpine CI flake. Adds two new Dockerfiles (Dockerfile.mysql-plain, Dockerfile.mysql-native-password) and reworks test/js/sql/mysql-tls/Dockerfile to run the stock mysql entrypoint at docker build time, baking a pre-initialized datadir into the image at /var/lib/mysql-init (sidestepping the base image's VOLUME /var/lib/mysql). Drops tmpfs and environment: from the mysql compose services (env now baked via ENV), changes every healthcheck interval from 1h to 5s, raises compose up --wait-timeout 60→180, and bumps five beforeAll hook timeouts 120s→240s to match. README architecture tree updated. No src/ code touched.
Security risks
None. Changes are confined to local test-container Dockerfiles, compose config, and test hook timeouts. No auth, crypto, or user-facing surface.
Level of scrutiny
Medium. It's test-only, but it's a substantive redesign of how three CI test containers are provisioned, using a somewhat non-obvious technique (build-time entrypoint run + alternate datadir to dodge VOLUME). If the baked image is wrong it takes out every mysql-backed test file. The PR description explicitly states Docker pulls were blocked in the authoring environment, so the new images were not built or run locally — correctness rests entirely on this PR's CI build (#70904).
Other factors
I left two nit-level comments on earlier revisions (missed sibling timeout in websocket-proxy.test.ts; README file-tree drift) — both were fixed in follow-up commits and are reflected in the current diff. The bug-hunting pass found nothing. The interval: 1h→5s and timeout bumps are mechanically sound. The removal of tmpfs is justified (fresh container → fresh CoW layer → fresh DB), but it plus the datadir relocation is the kind of infra decision a maintainer should glance at, and the pending alpine CI result is the actual verification. Deferring rather than approving so a human confirms the alpine lanes pass.
With three mysql images building in parallel (coordinator prestart starts mysql_plain, mysql_native_password and mysql_tls together), each RUN's mysqld --initialize contends for the host and on alpine CI runs past the previous 60-iteration poll, failing the prestart build. debian hosts finish the same parallel build in ~30s; the subsequent solo retry on alpine finishes in ~15s, so the approach is sound, only the bound was tight. 180 matches the compose up --wait-timeout.
…o runner AMIs prepare-ci.ts (run at AMI bake time) picks up the new Dockerfile.mysql-* build sections, so bun-mysql-plain/native-password/tls:local are pre-built in the runner and per-shard mysql container start is ~3s instead of paying the image build.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/docker/Dockerfile.mysql-native-password`:
- Around line 5-8: The baked MySQL credentials in the
Dockerfile.mysql-native-password setup are being fixed at image build time, so
runtime env-var overrides will be ignored once the datadir is initialized.
Update the MySQL initialization flow in this Dockerfile so the root password and
related credentials are applied at container startup instead of hardcoded via
ENV during build, following the same approach used to avoid freezing credentials
in Dockerfile.mysql-plain.
In `@test/docker/Dockerfile.mysql-plain`:
- Around line 14-22: The mysqld init/poll/shutdown sequence in this Dockerfile
is duplicated across multiple Dockerfiles, so extract it into a shared helper
script such as bake-mysql.sh and invoke it from Dockerfile.mysql-plain,
Dockerfile.mysql-native-password, and the mysql-tls Dockerfile. Keep the shared
logic in one place, parameterize only the credentials/flags each image needs,
and replace the inline RUN block with a call to the script so the polling and
shutdown behavior stays consistent everywhere.
- Around line 14-24: The MySQL image build step in Dockerfile.mysql-plain bakes
initialization data into /var/lib/mysql-init, so runtime MYSQL_ROOT_PASSWORD,
MYSQL_ALLOW_EMPTY_PASSWORD, and MYSQL_DATABASE overrides will be ignored by
docker-entrypoint.sh. Add a clear comment near the RUN/CMD setup explaining that
this is an intentional fixed test fixture and that the init directory prevents
runtime env-based reconfiguration. Use the existing docker-entrypoint.sh mysqld
bootstrap block and CMD ["mysqld", "--datadir=/var/lib/mysql-init"] as the
anchor points.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 286ec15e-361d-417a-bd6b-67545a41c91f
📒 Files selected for processing (11)
test/docker/Dockerfile.mysql-native-passwordtest/docker/Dockerfile.mysql-plaintest/docker/README.mdtest/docker/docker-compose.ymltest/docker/index.tstest/harness.tstest/js/sql/mysql-tls/Dockerfiletest/js/valkey/test-utils.tstest/js/valkey/valkey.test.tstest/js/web/websocket/autobahn.test.tstest/js/web/websocket/websocket-proxy.test.ts
There was a problem hiding this comment.
Both earlier nits are addressed and I found nothing further, but since this reworks the mysql CI container images and triggers an AMI rebake (with a manual [publish images] follow-up), it's worth a quick human sign-off from whoever owns the image-bake workflow.
Extended reasoning...
Overview
This PR is entirely test/CI infrastructure — no src/ runtime code is touched. It adds three baked-data-dir mysql Dockerfiles (Dockerfile.mysql-plain, Dockerfile.mysql-native-password, and the updated mysql-tls/Dockerfile), rewires docker-compose.yml to build them locally instead of using stock mysql:8.x images, drops every healthcheck interval from 1h to 5s, raises compose up --wait-timeout from 60→180 in test/docker/index.ts, bumps five beforeAll hook timeouts from 120s→240s to match, updates the test-docker README, and bumps scripts/bootstrap.sh to v38 so the next Linux AMI bake pre-builds the new images. The commit subject carries [build linux images] to bake throwaway AMIs for verification.
Security risks
None. This is test-container orchestration and CI image provisioning; no auth, crypto, permissions, or user-facing code paths are involved. The Dockerfiles use fixed test credentials (bun/empty) that were already in docker-compose.yml before this change.
Level of scrutiny
Medium. Nothing here ships in the Bun binary, and the worst-case failure mode is CI going red (immediately visible, trivially revertible). However, it does change how every mysql-backed test file gets its container across all Linux shards, removes tmpfs mounts (relying on CoW-layer freshness instead), and triggers the AMI-bake workflow — which per the bootstrap.sh header and PR description has a manual [build linux images] → [publish images] transition that someone needs to own once CI is green.
Other factors
Both nits I raised earlier (the missed websocket-proxy.test.ts timeout sibling and the README file-tree drift) were fixed in 0d3b798 and d25a0a1. Two further commits landed after: 2e3c961 added the bounded 180s readiness poll to the Dockerfile RUN step (a good defensive addition — the post-loop mysql ... -e 'SELECT 1' without redirection means a poll timeout fails the build rather than baking a bad image), and 3bfb1e7 added the bootstrap v38 bump. The PR description cites build 70904 with all 60 alpine shards passing on the pre-bake path. The design rationale (VOLUME discards build-time writes → use /var/lib/mysql-init; interval: 1h wedges --wait after start_period overshoot → use 5s) is sound and well-documented in comments. I'm deferring rather than approving primarily because the AMI rebake/publish workflow is an operational decision with a documented manual follow-up step, not because of any code concern.
…tgres services Same treatment as the mysql images: run the stock entrypoint once at docker build time against a PGDATA outside the base image's VOLUME /var/lib/postgresql/data, so cold container start is 'exec postgres' (~1-2s) instead of initdb + temp server + init scripts. On shards that prestart postgres alongside the three mysql builds, postgres_plain was taking 130-220s on alpine (28-57s on debian) because its compose build queued behind the parallel mysql image builds; with both sets pre-built in the AMI, none of that contention exists. Also drops the postgres tmpfs mounts and environment: blocks (now baked via ENV), and notes in the mysql-plain comment that the init-time MYSQL_* env vars are build inputs only.
|
On the throwaway v38 AMIs:
No build failures, no The remaining ~130s floor on alpine is pre-existing docker-daemon overhead, not the bake: a bare Ready for the |
|
@robobun push a commit to this branch with |
…to runner AMIs [build linux images] run 70954 is green on the throwaway v38 AMIs (292 passed; the two failures are darwin webview.test.ts and a debian x64-asan bun_http::http_thread SIGABRT, neither related to docker test infra). Publish the real -v38 tag.
|
Pushed b6e37ee with |
|
|
What
Fixes the recurring
application not healthy after 1m0sflake that takes out every mysql-backed test file on alpine shards (26030, 24850, 26063, 28632, sql-mysql.*, integration/mysql2), by baking pre-initialized data directories into the mysql and postgres test images so cold container start is ~2-3s instead of ~60s, and by removing the healthcheck configuration that turned a slow start into a permanent wedge.Dockerfile.mysql-plain,Dockerfile.mysql-native-password, and the mysql-tls Dockerfile run the stock entrypoint once atdocker buildtime withMYSQL_INITDB_SKIP_TZINFO=1against a sibling datadir (the base image'sVOLUME /var/lib/mysqldiscards build-time writes there). At container start the entrypoint sees the datadir is populated andexecsmysqlddirectly.Dockerfile.postgres-plain,Dockerfile.postgres-auth, and the postgres-tls Dockerfile do the same against aPGDATAoutsideVOLUME /var/lib/postgresql/data.intervaldrops from1hto5s.compose up --wait-timeoutgoes from 60 to 180 and the containerbeforeAllhook timeouts go to 240s.scripts/bootstrap.shbumped to v38 so the next Linux AMI bake runsprepare-ci.tsagainst the new compose file and pre-buildsbun-mysql-*:local/bun-postgres-*:localinto the runner. Until the v38 AMIs are published each shard still pays one image build under parallel prestart; afterwards it is justdocker run(~2-3s).Why
The ~62s mysql cold start breaks down as: ~39s loading
/usr/share/zoneinfointomysql.time_zone_*viamysql_tzinfo_to_sql, ~15smysqld --initialize-insecure, and ~8s of entrypoint setup plus the temp-server bounce. No test touches MySQL's named-timezone tables (the datetime-roundtrip test only varies the processTZ, not the MySQL sessiontime_zone), so the tzinfo load is dead weight, and the rest is deterministic and can run at image-build time instead of every container start. Postgres's own init (initdb + temp server + init scripts) is ~5-8s, but on alpine shards it queued behind the three parallel mysql builds and was observed at 130-220s ensure-to-ready.On alpine 3.23 CI hosts, mysql's ~62s overshot
start_period: 60s, and once start_period elapses Docker's health monitor switches fromstart_interval: 1stointerval: 1h. So the container sat athealth: startingfor an hour even though mysqld was accepting TCP connections two seconds later, and everycompose up --wait --wait-timeout 60timed out from then on. Each affected test file was retried four times at 60s apiece.From build 70876's alpine x64-baseline shard:
62s from entrypoint to ready, yet
docker compose pstwo minutes later still shows:because the next probe is scheduled for ~07:39.
Sampling the last 30 failed
:alpine: 3.23test-bun jobs, 20 were this exact error (x64, x64-baseline, aarch64). 0 of 20 sampled debian/ubuntu failures were.tmpfsis dropped for both: the baked data dir lives on the container's CoW layer, so a fresh container is still a fresh database/cluster and the light test workloads don't need RAM-backed I/O.interval: 5severywhere means that even if some future service overshoots itsstart_period, it recovers within one probe instead of freezingcompose up --waitfor an hour; aSELECT 1/pg_isreadyevery 5s is negligible and would need 30 consecutive failures (150s) to mark a running container unhealthy.Verification
compose build+up --waiton alpine completes in ~15s, debian completes all three in parallel in ~91s.[build linux images]so CI bakes throwaway v38 AMIs with the new images pre-built and runs the suite on them. Once green the subject can be switched to[publish images]per the bootstrap header.