Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition between the k8s-cms containers and database init. #23

Open
mrzzy opened this issue Apr 12, 2020 · 0 comments
Open

Race condition between the k8s-cms containers and database init. #23

mrzzy opened this issue Apr 12, 2020 · 0 comments
Labels
bug Something isn't working priority High Priority Issues

Comments

@mrzzy
Copy link
Collaborator

mrzzy commented Apr 12, 2020

There is a race condition between:

  • the initdb operation on the database, which setups the schema, db credentials etc.
  • the CMS containers trying to connect to the database.

This can been seen in a clean docker-compose up after a docker-compose down -v to clear any prior state: Shown in this pipeline run , we can observe the race condition in action:

  • the initdb operations to create cmsuser requires the database to be running.
  • the database runs, signalling to the wait-for-it scripts to start running the cms containers.
  • the initdb operations to create the cmsuser are not yet complete.
  • the k8s-cms containers attempt connect to the database with the credentials and fail.

The problem is mostly clearly observed in the docker-compose setup as it does not have a built in way to restart faulty containers. The health probes in the Kubernetes setup will detect that the container is not functioning correctly due the DB auth failure and restart the container. By then the initdb should already completed and the problem automatically resolved.

We should find a way to resolve this race condition as docker-compose setup requires two docker-compose ups in order to function correctly.

Possible solutions:

  • changing to the initdb DB port temporary to something else, so that wait-for-it scripts will continue to wait for when the DB is actually read for external connections.
@mrzzy mrzzy added bug Something isn't working priority High Priority Issues labels Apr 12, 2020
mrzzy added a commit that referenced this issue Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority High Priority Issues
Projects
None yet
Development

No branches or pull requests

1 participant