disqus / pgshovel

A change data capture system for PostgreSQL
Apache License 2.0
11 stars 3 forks source link

Ensure only one relay is running for a set at a given time. #1

Open tkaemming opened 9 years ago

tkaemming commented 9 years ago

This will ensure that only one publisher is writing to the log at a time, preventing out-of-order message delivery or interleaving messages from different publishers onto the same stream.

This could be implemented with a ZooKeeper lock, or an advisory lock on the origin database. (This can't be done with a LOCK statement on the origin database itself, since that lock would be released at the end of the transaction when a batch is committed to PgQ.)

I think the ideal solution here would be the ZooKeeper lock, although that would be more complex than using an advisory lock. (Using advisory locks for something like this feels like a bit of a hack to me since they aren't namespaced in any meaningful way.)