Repository navigation
fix: support MongoDB 9.0+ only (mongo:8 cannot start on Linux >= 6.19) - #12
Merged
Merged
Conversation
`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>
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11
Cause
The
mongo:8image 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-azureon bothubuntu-26.04(ubuntu-latest) andubuntu-24.04. The container crash-loops: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 (FactoryTestx3,Job\RepositoryTestx14); the rest never touch Mongo.Probed on the runner with
docker run+ ping (same kernel for all):mongo:8mongo:8+GLIBC_TUNABLES=glibc.pthread.rseq=0mongo:8.2(v8.2.12)mongo:7.0(v7.0.45)Changes
compose.yamlnow usesmongo:9.0(the 9.0.x patch line, not the floatingmongo:9tag, so CI does not move under us), with a comment explaining why not to go back tomongo:8. README says "MongoDB Server 9.0+" (it said 4.0+). No source change: nothing insrc/ortests/branches on the server version..travis.yml: dead config (PHP 7.2/7.3, amongodb-3.0apt source) for a project that requires PHP 8.4+ and runs on GitHub Actions.compose.yaml:mongoshping healthcheck onmongodb, deliberately not wired intophp'sdepends_on(service_healthywas reported to break worker spawning in the acceptance tests, see 8794825).Makefile:make upusesdocker 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
--waitare 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 phpstanand 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) withTimeoutException: Waiting for workers to be 1. The worker log shows why:waitForNumberOfWorkersToBe()calledretireDeadWorkers(now, 0s)on every 200ms poll, even while waiting for a worker to appear.Worker\Repository::deadWorkers()compareslast_seen_atagainstnowtruncated 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 nextrefresh(). 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 realconsideredDeadAfterthe truncation is irrelevant.This is most likely what the June attempts (longer timeouts, healthcheck in
depends_on, driver tweaks) were chasing. The8794825claim thatservice_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#3shows the sameFailed to resolve 'mongodb'signature and very likely has the same cause (unverified: its logs don't include the Mongo output).🤖 Generated with Claude Code