4 ms·
The pitfall of using PostgreSQL advisory locks with Go's DB connection pool
- erik_seaberg 7y agoTL;DR: PostgreSQL requires reserving a single connection for causally-related statements. Seems like a scaling problem for the C10K world, not just Go.
- jabwork 7y agoI ran into this same issue with python/SQLAlchemy. It's a connection pool thing
- paulddraper 7y agoEven more generally, pretty much any ACID database is gonna be a scaling problem for C10K.
- zeroimpl 7y agoSeems like if you tried to use transactions, you'd have the same problem?
- karmakaze 7y agoA transaction executes all commands using the same connection so it would have worked. The semantics are different though where the commands issued between the lock and unlock aren't atomic if issued on the same connection but not in a tx.
- AlfeG 7y agoFor transactions You should use different advisory lock tied to transaction: pg_advisory_xact_lock. This should solve problem even for sessions reuse and connection pooling