Skip to content

meta: give Db2 containers enough time to initialize before giving up - #18341

Merged
WikiRik merged 4 commits into
mainfrom
meta/db2-startup-timeout
Sep 8, 2026
Merged

WikiRik merged 4 commits into
mainfrom
meta/db2-startup-timeout

Conversation

@WikiRik

@WikiRik WikiRik commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Pull Request Checklist

  • Have you added new tests to prevent regressions? (N/A - dev tooling)
  • Does yarn test or yarn test-DIALECT pass with this change (including linting)?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)? (N/A)
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description Of Change

Since #18291 landed, db2 oldest and db2 latest are the most frequent database start failures in CI: 15 failed yarn start-db2-* steps across 9 runs, all with

Timeout of 150s exceeded when waiting for container to be healthy: sequelize-db2-oldest

Examples: db2 oldest (Node 22), db2 latest (Node 24).

Cause

Db2 creates the database on first start. The start step on successful main runs takes 127-213s, and locally on a fast machine the container first reports healthy after 175s. The Db2-only copy of wait-until-healthy.sh polls for 10 × 15s = 150s, which is right at the edge of a normal startup, so a slightly slow runner fails.

That copy also predates #18291: it still has the dead return_code check, prints nothing about the container on failure (which is why the job logs above say nothing useful), and sleeps a blind 15s after the container is healthy.

There is a second, latent problem. The image's setup script restarts the instance twice right after CREATE DATABASE:

21:45:21  SQL1026N  The database manager is already active.   <- db created, connectable
21:45:27  SQL1064N  DB2STOP processing was successful.
21:45:28  SQL1063N  DB2START processing was successful.
21:45:34  SQL1064N  DB2STOP processing was successful.
21:45:36  SQL1063N  DB2START processing was successful.
21:45:36  (*) Setup has completed.

A probe landing in one of those ~6s windows marks the container healthy, after which the instance goes down again and check-connection.ts gets ECONNREFUSED. The old sleep 15 was presumably guarding against this.

Changes

  • Delete dev/db2/wait-until-healthy.sh; both start.sh use the shared dev/wait-until-healthy.sh with HEALTHCHECK_TIMEOUT=600, so a slow runner has headroom while a genuinely stuck container still fails in minutes rather than hours, and the health probes + container logs are dumped on failure.
  • The healthcheck additionally requires /database/config/.shared-data/setup_complete, the marker the image's setup_db2_instance.sh touches right after the last restart (same path in 11.5.5.1 and 12.1.4.0). This replaces the blind sleep.
  • start_period: 300s so the container is not reported unhealthy while it is legitimately still creating the database.

Verification (local, icr.io/db2_community/db2:11.5.5.1)

Healthcheck command exit
after setup completed 0
marker missing 1
marker present, database unreachable 1

Note: touches the same start.sh files as #18340, expect a trivial conflict in whichever lands last.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved DB2 startup reliability by waiting for database setup to complete before health checks run.
    • Extended the startup grace period and health-check timeout to accommodate longer initialization times.
    • Corrected the health-check script path used during DB2 startup.
  • Chores
    • Removed the obsolete DB2-specific health-check helper script.

db2 oldest/latest jobs fail regularly in `yarn start-db2-*` with
"Timeout of 150s exceeded when waiting for container to be healthy".
Db2 creates the database on first start, and successful runs of the
same step on main take 127-213s, so the 150s budget of the Db2-only
copy of wait-until-healthy.sh is right at the edge of normal. Locally,
on a fast machine, the container first reports healthy after 175s.

That copy also predates #18291: it still has the dead `return_code`
check, prints nothing about the container on failure, and sleeps a
blind 15s after the container is healthy.

Remove it and use the shared dev/wait-until-healthy.sh, which
supports HEALTHCHECK_TIMEOUT and dumps the health probes and container
logs when it gives up. Db2 gets a 600s budget so a slow runner has
headroom while a genuinely stuck container still fails in minutes
rather than hours.

The setup script restarts the instance twice after creating the
database, so a probe can pass in a short window before a restart.
The healthcheck now also requires the image's own setup-complete
marker, which is created after the last restart. This replaces the
blind 15s sleep. start_period goes to 300s so the container is not
reported unhealthy while it is legitimately still creating the
database.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 8028be71-6557-42ce-9ddf-b3afbb8af267

📥 Commits

Reviewing files that changed from the base of the PR and between 0bf5569 and 1a223c1.

📒 Files selected for processing (5)
  • dev/db2/latest/docker-compose.yml
  • dev/db2/latest/start.sh
  • dev/db2/oldest/docker-compose.yml
  • dev/db2/oldest/start.sh
  • dev/db2/wait-until-healthy.sh
💤 Files with no reviewable changes (1)
  • dev/db2/wait-until-healthy.sh

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The DB2 healthchecks now wait for setup completion and allow 300 seconds for startup. Both DB2 startup scripts use a 600-second timeout and call the repository-level health wait script. The DB2-specific wait script was removed.

Changes

DB2 health readiness

Layer / File(s) Summary
DB2 healthcheck readiness
dev/db2/latest/docker-compose.yml, dev/db2/oldest/docker-compose.yml
Both healthchecks verify .shared-data/setup_complete before running DB2 connectivity queries. Both startup periods increased from 15s to 300s.
Startup health wait integration
dev/db2/latest/start.sh, dev/db2/oldest/start.sh, dev/db2/wait-until-healthy.sh
Both startup scripts set HEALTHCHECK_TIMEOUT=600 and call the repository-level wait script. The DB2-specific wait script was removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to e3efa

DB2 startup now waits for setup completion and allows more time for health checks, reducing premature CI failures without an identified current-head merge risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: increasing Db2 startup time and health-check tolerance to reduce initialization failures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch meta/db2-startup-timeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@WikiRik
WikiRik marked this pull request as ready for review September 7, 2026 15:04
@WikiRik
WikiRik requested a review from a team as a code owner September 7, 2026 15:04
@WikiRik
WikiRik requested review from ephys and sdepold September 7, 2026 15:04
@WikiRik
WikiRik enabled auto-merge (squash) September 8, 2026 07:26
@WikiRik
WikiRik merged commit ccb8d2d into main Sep 8, 2026
75 checks passed
@WikiRik
WikiRik deleted the meta/db2-startup-timeout branch September 8, 2026 08:31
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.

2 participants