Skip to content

docker-compose: add explicit dependency between postgres containers - #2248

Merged
alxndrsn merged 3 commits into
getodk:nextfrom
alxndrsn:postgres-container-interdependency
Sep 17, 2026
Merged

alxndrsn merged 3 commits into
getodk:nextfrom
alxndrsn:postgres-container-interdependency

Conversation

@alxndrsn

@alxndrsn alxndrsn commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

This PR contains work foundational to:


This seems to prevent a race condition related to volume creation order:

Container central-postgres14-1  Error response from daemon: failed to mkdir /var/lib/docker/volumes/central_postgres14/_data/data: mkdir /var/lib/docker/volumes/central_postgres14/_data/data: file exists

This error was seen ~3% of the time when running:

  • postgres container based on tianon/postgres-upgrade:9.6-to-14
  • postgres14 container based on pgautoupgrade/pgautoupgrade:17.11-trixie

Given the vague nature of both the error itself, and reproduction circumstances, it seems prudent to introduce this dependency.

The dependency itself seems logical, as the postgres14 container should be waiting for the postgres container to create a flag file before PostgreSQL itself starts up.

See:

What has been done to verify that this works as intended?

  • ran CI 200 times and didn't see the error repeat

Why is this the best possible solution? Were any other approaches considered?

Could just ignore it, and hope it never happens to a self-hoster.

How does this change impact users? Describe intentional behavior changes from code updates. What are the regression risks?

Should prevent container failure. It's unknown if the failure is temporary, or permanent.

Is this change user-facing or otherwise noteworthy to users? If so, please add an entry for it in CHANGELOG.md.

There's no evidence a user has ever experienced this, so it's unclear if it's helpful to add to the CHANGELOG.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

Probably not.

alxndrsn added 2 commits September 15, 2026 11:22
This seems to prevent a race condition related to volume creation order:

	Container central-postgres14-1  Error response from daemon: failed to mkdir /var/lib/docker/volumes/central_postgres14/_data/data: mkdir /var/lib/docker/volumes/central_postgres14/_data/data: file exists

This error was seen ~3% of the time when running:

* `postgres` container based on `tianon/postgres-upgrade:9.6-to-14`
* `postgres14` container based on `pgautoupgrade/pgautoupgrade:17.11-trixie`

Given the vague nature of both the error itself, and reproduction circumstances, it seems prudent to introduce this dependency.

The dependency itself seems logical, as the `postgres14` container should be waiting for the `postgres` container to create a flag file before PostgreSQL itself starts up.

See:

* moby/moby#47021
* https://forums.docker.com/t/error-while-creating-mount-source-path-after-docker-desktop-update-to-v4-35/144676
@alxndrsn
alxndrsn marked this pull request as ready for review September 15, 2026 12:37
with:
node-version-file: test/package.json
- run: cd test/nginx && npm clean-install --no-audit
- run: touch ./files/allow-postgres14-upgrade

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now required as starting the service container triggers starting the postgres14 container, which now triggers starting this postgres container.

@alxndrsn
alxndrsn merged commit 7a594a7 into getodk:next Sep 17, 2026
5 checks passed
@alxndrsn
alxndrsn deleted the postgres-container-interdependency branch September 17, 2026 08:20
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