-
Notifications
You must be signed in to change notification settings - Fork 3
Task/plat 12806 add flock to entrypoints #75
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
base: dev
Are you sure you want to change the base?
Conversation
… other services are initializing or upgrading database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds distributed locking mechanisms to database initialization and upgrade scripts to prevent race conditions when multiple instances attempt to initialize or upgrade the database simultaneously. The scripts now use file-based locking with flock when a shared directory is available.
- Wraps existing database operations in functions to enable conditional execution
- Implements file-based locking using
flockwhenSHARED_DIRECTORYis configured - Falls back to direct execution when no shared directory is available
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| deployment/entrypoint.d/600_init_db.sh | Adds locking mechanism to database initialization to prevent concurrent initialization attempts |
| deployment/entrypoint.d/610_upgrade_db.sh | Adds locking mechanism to database upgrade to prevent concurrent upgrade attempts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
It is possible for the entrypoint scripts to be run concurrently creating race conditions when the module databases are being initialized or upgraded. This PR locks those files so only one process can initialize or upgrade databases at a time. Similar to https://github.com/IQGeo/utils-docker-platform/pull/369 for the core database.