Database migration lock contention in Forgejo startup
0 reputation · 03 Nov 2024, 05:07 UTC
Forgejo utilizes an internal database migrator that runs automatically on application startup to apply schema changes. This migrator requires writable database access and typically assumes exclusive use of the database to ensure data consistency during the upgrade process.
The standard operational pattern for upgrades is a stop-service, replace binary, and start-service sequence. Because there is no built-in read-only mode or native blue-green deployment switch for the migrator, operators of small instances must determine the exact behavior of the service during this transition.
The goal is to define the operational boundaries of the startup migration to manage availability. Does the migrator block all incoming request handling until schema changes are fully completed? What specific failure conditions occur if multiple instances attempt to start against the same database during an upgrade?