Closed P4rpleSky closed 10 months ago
@P4rpleSky thanks for filing.
What version of Npgsql are you using? Can you try with lower versions and seed if the result is the same?
Also, any chance you’re using pg bouncer? Someone reported a problem related to pg prepared statements here: https://github.com/madelson/DistributedLock/issues/168
@madelson Thanks for your reply! In the test application above, I didn't use anything other than your package, so I believe the version of Npgsql is the same as in v1.0.4 of your library (v5.0.4).
The issue that you mentioned in your comment helped me find the problem. I asked my colleagues: We have pgbouncer running in transaction mode. He does not allow the use of prepared statements. When I set ShouldPrepareCommands
to false
in library code, everything works well. We have a lot of high-load services that are not allowing us to turn this setting off. Moreover, I tried to set Max Auto Prepare=0
in my connection string, but this did not work.
Something is still unclear to me: how do synchronous methods work well, but async — not? As I understand it, they are using the same code.
We'll try to solve this problem somehow on our side. I'll keep you in touch if we can do something with it quickly.
Appreciate the follow-up @P4rpleSky ! I’m going to close this issue as a dupe of #168 . Lets continue any future discussion on that issue.
I agree that it is strange that the asynchrony methods work; likely there’s some difference in Npgsql’s implementation.
I would like the library to work seamlessly with pg_bouncer (assuming connection-based locks work with it in general), so I’m open to changing distributedlock to for that purpose.
Hi! I'm trying to make a test console application with advisory locks for PostgreSQL. Here's the code:
It works fine on the first launch. After that, the exception is thrown:
I can fix this problem by running the SQL query
deallocate all
directly in my DB after every launch. Synchronous methodsAcquire
andTryAcquire
work fine, but their async-analogues fail, as I described above.Do you have any idea what I can do to avoid this? Thank you in advance for any suggestions.