mysticmind-postgresembed
mysticmind-postgresembed copied to clipboard
Calling commit multiple times from an implicit transaction causes the code to hang
Hi, We are using your embedded postgres library for unit tests and it has been working great. However, we have recently noticed that the tests seem to hang during a parallel execution.
I have managed to reproduce this behavior in a separate solution and it seems to be related to the fact we are attempting to call "commit" from an implicit transaction multiple times. Our code is attempting to perform a "set statement_timeout" as per articles such as; https://stackoverflow.com/questions/24092463/psql-set-default-statement-timeout-as-a-user-in-postgres
Here is the project used to reproduce this. The instructions are in the readme of the repro. https://github.com/AlexFlat/NPGSQLConnectionSetTimeout/tree/master
I am logging this here as I am unable to reproduce this using a "real" postgres install and wanted to see if there was some setting we have missed when configuring the PGServer.
Thanks in advance for your time
@AlexFlat I shall have a look at this issue and get back to you. Following are the possible quick remedies:
- pass a server param
statement_timeout
and the value so that you can use it for all SQL queries without doing it for every call? - Adjust the set statement to not add
commit
if you are not using a transaction.
Please let me know your thoughts.
@mysticmind thanks for the quick reply.
Responses to your suggestions;
- pass a server param statement_timeout and the value so that you can use it for all SQL queries without doing it for every call? [We need to be able to adjust this timeout on a per-request basis so we cannot hard code this for the server]
- Adjust the set statement to not add commit if you are not using a transaction. [I discussed this with my colleagues, however the concern was that the statement will not take effect for the current connection unless the "commit;" is included. Happy to be proved wrong on this one, but all the references on the web seem to always include the "commit;"]
Thanks again for the quick reply
I am not sure what I could fix on this. Closing this for now.