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

Database Availability Race Condition during Intialisation #565

Open
sierja opened this issue Mar 2, 2024 · 0 comments
Open

Database Availability Race Condition during Intialisation #565

sierja opened this issue Mar 2, 2024 · 0 comments

Comments

@sierja
Copy link

sierja commented Mar 2, 2024

There is a race condition when bring up this stack with Docker Compose, the application will start before the MySQL instance is ready, preventing the schema being loaded and the seeding from occurring which poisons the stack's persistence.

The db service in the docker-compose.yml should have a health check, such as:

healthcheck:
  test: mysqladmin -p$$MYSQL_ROOT_PASSWORD ping -h localhost
  interval: 20s
  start_period: 10s
  timeout: 10s
  retries: 3

The app service in the docker-compose.yml should require db as a health dependency , such as:

depends_on:
  db:
    condition: service_healthy
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

No branches or pull requests

1 participant