commanded / eventstore

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

Namespace advisory lock to prevent clash with other applications #166

Closed slashdotdash closed 4 years ago

slashdotdash commented 5 years ago

Prevent lock collision with application level Postgres advisory lock usage and other libraries.

Use pg_try_advisory_lock(key1 int, key2 int) instead of pg_try_advisory_lock(key bigint).

See this commit to Oban for an example implementation which uses the identity of a table to namespace advisory locks. For EventStore we should use the subscriptions table identity as the namespace.

slashdotdash commented 4 years ago

Fixed in 2b4e4b364bb1af9ea7228f46050063186b233464.