commanded / eventstore

Event store using PostgreSQL for persistence
MIT License
1.06k stars 146 forks source link

Use database lock to prevent migrations from running concurrently #204

Closed slashdotdash closed 4 years ago

slashdotdash commented 4 years ago

Use Postgres advisory lock when migrating an event store database to ensure only a single migration can run at a time. This protects against running migrations concurrently by mistake.

A database lock is used to ensure only one migration can run at a time, preventing issues with multi-node deployments where the migration is automatically run on startup where two or more nodes starting at the same time may attempt to migrate simultaneously.

Fixes #192.