Skip to content

meta: make Oracle container startup fail fast instead of hanging - #18444

Merged
WikiRik merged 2 commits into
mainfrom
wikirik-agent/oracle-startup-fail-fast
Sep 20, 2026
Merged

WikiRik merged 2 commits into
mainfrom
wikirik-agent/oracle-startup-fail-fast

Conversation

@wikirik-agent

@wikirik-agent wikirik-agent commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Supersedes #18339, which this replaces with an explicit healthcheck budget and full verification on both images.

Description of Changes

The healthcheck was not a healthcheck

sqlplus user/pass@service with no -L and no stdin prompts for credentials on a rejected logon, reads EOF, and exits 0. Measured against both real images:

probe good service bogus service (ORA-12514) wrong password (ORA-01017)
old, sqlplus … (no -L, no stdin) 0 0 0
new, echo 'select 1 from dual;' | sqlplus -L -S … 0 1 1

Identical results on gvenzl/oracle-free:23.26.3-slim and gvenzl/oracle-xe:18-slim. The old probe only tested whether the sqlplus binary could start, so wait-until-healthy.sh returned on the first probe every time and the blind sleep 30s was doing 100% of the actual waiting.

…which is why jobs hung for six hours

start.sh then ran docker exec -t … sqlplus without -L. On a failed logon sqlplus drops into its interactive logon prompt on the allocated TTY and waits forever:

bogus service
docker exec -t … sqlplus hung (killed at my 15s limit)
docker exec … sqlplus -L exits 1 immediately

Three jobs cited in #18339 each ran exactly 6h00m before being cancelled by the job timeout (1, 2, 3). This flake is rare — one occurrence in the 7 days to 2026-09-20, against 4 for db2 image pulls — but it is by far the most expensive per occurrence, which is the argument for fixing it.

Changes

  • healthcheck (both): pipe a real query into sqlplus -L -S, so it passes only on a successful logon to XEPDB1 through the listener. timeout 1s → 5s, plus a start_period so boot-time probe failures are not reported as unhealthy.
  • start.sh (both): drop the TTY, add -L, remove the blind sleep 30s — safe now that the probe is genuine — and set HEALTHCHECK_TIMEOUT=300 explicitly, matching what dev/db2/*/start.sh already does. oldest now uses the same easy-connect string as latest.
  • privileges.sql: whenever sqlerror / whenever oserror so a failing statement exits non-zero instead of silently continuing.

Verification

Run against the real images, both flavours end to end — nothing assumed from the other:

oracle-xe:18-slim (oldest) oracle-free:23.26.3-slim (latest)
time to healthy, new probe 26s / 30s 30s
full start.sh 27s, exit 0 pipeline verified step by step
privileges.sql on fresh DB exit 0, no ORA- exit 0, no ORA-
sequelize.authenticate() Connected to oracle 18.4.0 Connected to oracle 23.26.3

Both connect-string forms (@XEPDB1 and @localhost:1521/XEPDB1) were confirmed working on 18-slim before switching oldest over, rather than assumed.

Failure path — a service that never registers, which is the state the hung jobs were in:

Timeout of 20s exceeded when waiting for container to be healthy: sequelize-oracle-oldest (last state: unhealthy)
--- healthcheck probes ---
{"Status":"unhealthy","FailingStreak":22,"Log":[{… "ExitCode":1,"Output":"ERROR:\nORA-12514: TNS:listener does not currently know of service requested in connect\ndescriptor\n…

wait-until-healthy.sh exits 1 within the configured budget and surfaces ORA-12514 directly — the same error that was the last log line of the six-hour jobs, now reported instead of buried.

whenever sqlerror exit failure cannot break repeat runs: neither Oracle compose file declares a volume (docker compose config --volumes is empty) and start.sh always runs down --remove-orphans first, so the DB is always fresh. Verified a down/up cycle resets it and privileges.sql succeeds again. Re-running it against a live DB does now exit 1 (ORA-01920), which is the intended loud failure.

There is no scenario where this is worse than today:

situation before after
Oracle ready quickly ~3s false pass + 30s sleep real pass, ~30s
Oracle slow or broken probe lies, docker exec hangs → 6h fails at the budget with probe output + logs
container exits during startup opaque container … is not running wait-until-healthy.sh catches exited, dumps logs

List of Breaking Changes

None — development tooling only.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved Oracle service readiness checks for more reliable startup detection.
    • Increased health-check tolerance during database initialization and added a bounded wait for readiness.
    • Improved database connection handling during startup and privilege setup.
    • Startup now reports SQL or operating-system errors as failures instead of continuing silently.

The Oracle healthcheck ran sqlplus without -L and with no stdin. On a rejected
logon sqlplus prompts for credentials, reads EOF and exits 0, so the container
was reported healthy as soon as the binary could run, whether or not the service
was reachable. The blind `sleep 30s` in start.sh was doing all of the waiting.

start.sh then ran `docker exec -t ... sqlplus` without -L, so a failed logon sat
at an interactive prompt on the allocated TTY and waited for input that never
came. Jobs hit the 6 hour limit instead of failing.

Pipe a real query into `sqlplus -L -S` in the healthcheck so it only passes on a
successful logon, drop the TTY and add -L to the start.sh call, remove the sleep,
and set an explicit HEALTHCHECK_TIMEOUT as dev/db2 already does. privileges.sql
exits non-zero on error instead of silently continuing.

Supersedes #18339.

Co-Authored-By: Claude Opus 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8d5597bf-78b9-41de-8f2a-4350d330a136

📥 Commits

Reviewing files that changed from the base of the PR and between 17c49ec and c48d8c7.

📒 Files selected for processing (5)
  • dev/oracle/latest/docker-compose.yml
  • dev/oracle/latest/start.sh
  • dev/oracle/oldest/docker-compose.yml
  • dev/oracle/oldest/start.sh
  • dev/oracle/privileges.sql

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


📝 Walkthrough

Walkthrough

Oracle healthchecks now run explicit SQL queries with longer timeouts and startup grace periods. Startup scripts use bounded health waits and non-interactive SQL*Plus connections. Privilege setup now exits on SQL or operating-system errors.

Changes

Oracle startup reliability

Layer / File(s) Summary
Oracle healthcheck validation
dev/oracle/latest/docker-compose.yml, dev/oracle/oldest/docker-compose.yml
Both Oracle healthchecks run select 1 from dual through non-interactive SQL*Plus, use a five-second timeout, and allow 120 seconds for startup.
Bounded startup and privilege initialization
dev/oracle/latest/start.sh, dev/oracle/oldest/start.sh, dev/oracle/privileges.sql
Startup scripts use a 300-second health wait and non-interactive SQL*Plus connections. The privilege script exits on SQL and operating-system errors.

Priority: ⬇️ Low

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

Change: Bug fix

🚥 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 and concisely describes the main change: making Oracle container startup fail fast instead of hanging.
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
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@WikiRik
WikiRik marked this pull request as ready for review September 20, 2026 11:27
@WikiRik
WikiRik requested a review from a team as a code owner September 20, 2026 11:27
@WikiRik
WikiRik enabled auto-merge (squash) September 20, 2026 11:27
@WikiRik
WikiRik merged commit 4155737 into main Sep 20, 2026
76 checks passed
@WikiRik
WikiRik deleted the wikirik-agent/oracle-startup-fail-fast branch September 20, 2026 11:54
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