Skip to content

fix: support MongoDB 9.0+ only (mongo:8 cannot start on Linux >= 6.19) - #12

Merged
dbellettini merged 7 commits into
mainfrom
fix/mongodb-readiness
Oct 31, 2026
Merged

dbellettini merged 7 commits into
mainfrom
fix/mongodb-readiness

Conversation

@dbellettini

@dbellettini dbellettini commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #11

Cause

The mongo:8 image refuses to start on Linux kernel 6.19 or newer (SERVER-121912, a tcmalloc/rseq incompatibility affecting MongoDB 8.0+). GitHub's runners now ship such a kernel: 7.0.0-1017-azure on both ubuntu-26.04 (ubuntu-latest) and ubuntu-24.04. The container crash-loops:

MongoDB cannot start: Linux kernel versions 6.19 and newer has a known incompatibility with this version of MongoDB.

A restarting container is not resolvable on the Docker network, which is where the tests' Failed to resolve 'mongodb' came from. The 17 failing tests are exactly the ones that connect (FactoryTest x3, Job\RepositoryTest x14); the rest never touch Mongo.

Probed on the runner with docker run + ping (same kernel for all):

Image Result
mongo:8 down, kernel guard
mongo:8 + GLIBC_TUNABLES=glibc.pthread.rseq=0 down, same guard (the workaround does not help)
mongo:8.2 (v8.2.12) up
mongo:7.0 (v7.0.45) up

Changes

  • Support MongoDB 9.0+ only. This is a portfolio project that nobody uses any more, so there is no reason to hedge across server versions. compose.yaml now uses mongo:9.0 (the 9.0.x patch line, not the floating mongo:9 tag, so CI does not move under us), with a comment explaining why not to go back to mongo:8. README says "MongoDB Server 9.0+" (it said 4.0+). No source change: nothing in src/ or tests/ branches on the server version.
  • Delete .travis.yml: dead config (PHP 7.2/7.3, a mongodb-3.0 apt source) for a project that requires PHP 8.4+ and runs on GitHub Actions.
  • compose.yaml: mongosh ping healthcheck on mongodb, deliberately not wired into php's depends_on (service_healthy was reported to break worker spawning in the acceptance tests, see 8794825). Makefile: make up uses docker compose up -d --wait.
  • ci.yml: a "Start services" step that prints the kernel version and, on failure, the Docker version, container state and Mongo logs. That is what exposed the cause here; before it, a crash-looping Mongo only showed up as 17 cryptic test errors.
  • tests/.../BaseAcceptanceTestCase.php: waitForNumberOfWorkersToBe() no longer retires workers while waiting for the roster to grow. See "Second cause" below.

The healthcheck and --wait are not what fixes #11, but they cover a real startup race seen on ubuntu-24.04 in June (connection refused, run 27399442450) and make this kind of failure readable.

Verification

CI on this branch (MongoDB 9.0.4, kernel 7.0.0-1017-azure): green on PHP 8.4 and 8.5, first time since 2025-11-18 (unit 9, integration 98, acceptance 18 tests). make phpstan and php-cs-fixer clean. The lockfile of #10 (chore: composer update) was also run on top of this branch locally: all green.

Second cause: acceptance tests retiring their own workers

With Mongo reachable, the acceptance suite still failed on FaultToleranceTest (1-2 tests per job, varying between runs) with TimeoutException: Waiting for workers to be 1. The worker log shows why:

Thrown an Exception: LogicException
Document with _id ... is missing!

waitForNumberOfWorkersToBe() called retireDeadWorkers(now, 0s) on every 200ms poll, even while waiting for a worker to appear. Worker\Repository::deadWorkers() compares last_seen_at against now truncated to the whole second, so a worker that registered in the previous second counted as dead: its roster document was deleted, and it crashed on its next refresh(). The helper now retires only when more workers are registered than expected (i.e. while the roster has to shrink). src/ is untouched: with a real consideredDeadAfter the truncation is irrelevant.

This is most likely what the June attempts (longer timeouts, healthcheck in depends_on, driver tweaks) were chasing. The 8794825 claim that service_healthy "breaks worker spawning" is probably this same race (unverified, I did not retry it).

Local acceptance suite (make test-acceptance-short, Docker Desktop, kernel 7.0.14): 0/10 green before, 15/15 after.

Notes

  • recruiterphp/concurrency#3 shows the same Failed to resolve 'mongodb' signature and very likely has the same cause (unverified: its logs don't include the Mongo output).

🤖 Generated with Claude Code

dbellettini and others added 5 commits October 30, 2026 14:43
`docker compose up -d` returns once the containers are started, not once
mongod accepts connections. PHPUnit starts ~0.4s later, and the 17
integration tests that open a connection (FactoryTest, Job\RepositoryTest)
fail because Factory::getMongoDb() connects eagerly with
serverSelectionTryOnce. The wait step that used to cover this was removed
in 295b933.

- compose.yaml: add a mongosh ping healthcheck to the mongodb service. It
  is deliberately not wired into php's depends_on, since
  `condition: service_healthy` was reported to break worker spawning in
  the acceptance tests (8794825).
- Makefile: `make up` now uses `docker compose up -d --wait`, so every test
  target (and local use) waits for MongoDB.
- ci.yml: before the tests, check that `mongodb` resolves from the PHP
  container, retrying for up to 30s, and dump diagnostics on failure. On
  ubuntu-26.04 the failure reads "Failed to resolve 'mongodb'" rather than
  "connection refused"; this step tells a startup race from a real DNS
  problem.

Refs #11

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The first CI run on this branch failed in `make up` with
"container recruiter_mongodb is unhealthy", about 1s after the container
started, despite `retries: 30`. The step aborted before the diagnostics
ran, so there were no Mongo logs.

Run the DNS check even if `make up` fails, and on any failure print the
Docker version, container state and health log, and the Mongo logs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…= 6.19)

The diagnostics added in the previous commit showed the real cause of #11:

  MongoDB cannot start: Linux kernel versions 6.19 and newer has a known
  incompatibility with this version of MongoDB. (SERVER-121912)

`ubuntu-latest` now resolves to ubuntu-26.04, whose kernel is affected, so
the mongodb container crash-loops. A restarting container is not resolvable
on the Docker network, which is why the tests failed with
"Failed to resolve 'mongodb'". The DNS check passed once Mongo was up
(this was verified on the failing runner), so DNS was never the problem.

- Pin test-fast and test-long to ubuntu-24.04 until MongoDB ships a fix.
- Replace the DNS check with a plain "Start services" step that prints the
  kernel version and, on failure, the container state and Mongo logs.

The healthcheck and `up --wait` stay: they still cover the startup race
seen on ubuntu-24.04 in June, and make this kind of failure readable.

Refs #11

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The pin did not help: the ubuntu-24.04 runner image now ships kernel
7.0.0-1017-azure, so mongod 8 still refuses to start (SERVER-121912, a
tcmalloc/rseq incompatibility with Linux >= 6.19 affecting MongoDB 8.0+).

Revert the pin, and add a throwaway workflow that only runs `docker run` +
ping for a few candidates on the runner (mongo:8, mongo:8 with
GLIBC_TUNABLES=glibc.pthread.rseq=0, mongo:7.0, mongo:8.2), so the fix is
chosen from verified results. mongo-probe.yml is to be deleted before merge.

Refs #11

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This is the actual cause of #11. The `mongo:8` image refuses to start on
Linux kernel 6.19 or newer (SERVER-121912, a tcmalloc/rseq incompatibility
affecting MongoDB 8.0+) and the container crash-loops. GitHub's runners now
ship such a kernel (7.0.0-1017-azure on both ubuntu-26.04 and ubuntu-24.04),
so every connecting test failed with "Failed to resolve 'mongodb'": a
restarting container is not resolvable on the Docker network.

Probed on the runner with `docker run` + ping:
  mongo:8                         DOWN (kernel guard)
  mongo:8 + glibc rseq=0          DOWN (same guard, workaround is useless)
  mongo:8.2 (v8.2.12)             UP
  mongo:7.0 (v7.0.45)             UP

Locally on mongo:8.2: unit and integration suites pass (98 tests, 174
assertions). Drop the temporary probe workflow.

Refs #11

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dbellettini dbellettini changed the title fix: wait for MongoDB to be healthy before running tests fix: use mongo:8.2 (mongo:8 cannot start on Linux >= 6.19) Oct 30, 2026
Nobody uses this project any more, so stop hedging across server versions
and target a single modern one.

- compose.yaml: mongo:8.2 -> mongo:9.0 (the 9.0.x patch line, not the
  floating `mongo:9` tag, so CI does not move under us). The comment keeps
  the reason not to go back to `mongo:8`: that image refuses to start on
  Linux >= 6.19, which GitHub's runners ship (SERVER-121912).
- README: "MongoDB Server 4.0+" -> "9.0+".
- Delete .travis.yml: dead config (PHP 7.2/7.3, a mongodb-3.0 apt source)
  for a project that requires PHP 8.4+ and runs on GitHub Actions.

No source change: nothing in src/ or tests/ branches on the server version.
Verified locally on v9.0.4: unit and integration suites pass (98 tests,
174 assertions).

Refs #11

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dbellettini dbellettini changed the title fix: use mongo:8.2 (mongo:8 cannot start on Linux >= 6.19) fix: support MongoDB 9.0+ only (mongo:8 cannot start on Linux >= 6.19) Oct 30, 2026
waitForNumberOfWorkersToBe() called retireDeadWorkers(now, 0s) on every
poll. Worker\Repository::deadWorkers() truncates "now" to the second, so
a worker that registered in the previous second was considered dead and
its roster document deleted. The worker then crashed on its next refresh
with "Document with _id ... is missing!", and the test timed out waiting
for it ("Waiting for workers to be 1").

This was the actual cause of the acceptance failures that earlier
attempts tried to fix with longer timeouts, healthchecks and driver
tweaks. Retire only when the roster has to shrink.

Local acceptance suite: 0/10 green before, 15/15 after.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dbellettini
dbellettini marked this pull request as ready for review October 31, 2026 20:40
@dbellettini
dbellettini merged commit 7e8d654 into main Oct 31, 2026
6 checks passed
@dbellettini
dbellettini deleted the fix/mongodb-readiness branch October 31, 2026 20:41
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.

CI Pipeline: integration tests fail on main (cannot resolve MongoDB host), failing since at least 2026-06-12

1 participant