-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Postgres distributed lock using PgBouncer connection pooler #168
Comments
@tiago156 this is an interesting issue and not one I was aware of. Suporting this will required a change to the library. A few questions:
|
@tiago156 have you looked at https://stackoverflow.com/questions/20150503/prepared-statement-doesnt-exist ? Seems like possibly this is fixable with PG configuration? |
@P4rpleSky im not opposed to adding support for that and in fact we do support the equivalent capability for SQL server. IIRC the reason I didn’t do it initially was that in SQL server I had bad experiences with transaction-based locks. At least on that database keeping transactions open for a long time can cause issues like blocking the transaction log from being flushed. I have no idea if the same is true for Postgres (of course, not all applications need to hold distributed locks for a long time). can you point me to the resource where you were reading about using transaction-based locks with pg_bouncer? |
@madelson Here are some useful links:
The problem with prepared statements is just the beginning. My comment above is related to this type of problem: if our application unexpectedly shuts down (or our database connection is closed) while having a session-based lock, we won't be sure that Maybe this problem is somehow solved by calling |
@P4rpleSky thanks for the great info. I think we should add transactional pg lock support to the library. would you or @droivan (or anyone else) be interested in contributing? |
@tiago156 @P4rpleSky @droivan I've implemented transaction-based locking in the upcoming release. Can anyone confirm that we do not need to disable prepared statements (per the original ask)? |
@madelson I can confirm the prepared statement exception has disappeared once I used |
Also, you need to change max_prepared_statements to a non-zero value in |
Hello,
my postgres database is behind a PgBouncer connection pooler with transaction pooling and it does not allow prepared statements, so its failing as the Distributed Lock postgres implementation uses prepared statement:
DistributedLock/src/DistributedLock.Postgres/PostgresDatabaseConnection.cs
Line 26 in 00c0f4e
I was not able to find a way to disable it through configuration/parameters, do you have any recommendation on this case?
Thank you.
The text was updated successfully, but these errors were encountered: