pact-foundation / pact_broker

Enables your consumer driven contracts workflow
http://pactflow.io
MIT License
708 stars 177 forks source link

feat(clean): use postgres advisory locks to ensure only one process can run a clean at a time #672

Closed bethesque closed 8 months ago

bethesque commented 8 months ago

https://github.com/pact-foundation/pact_broker/issues/488

Use a Postgres advisory lock to ensure that only one "clean" rake task can run at a time. This allows a cron schedule to be used on the Pact Broker Docker image when deployed on a multi-instance architecture, without all the instances stepping on each other's toes. Any tasks that attempt to run while a clean job is running will skip the clean and exit with a message and a success code.

Use Postgres advisory locks to ensure that only one thread can run a schema or data migration at a time during startup.