Closed avkhozov closed 6 years ago
Like you said, you're using transactions incorrectly here. I don't think this is a bug that needs to be fixed. But of course i'm open to ideas for making Mojo::Pg
better.
To be clear, after starting a transaction it's your responsibility to make sure you only run queries using the same Mojo::Pg::Database object, or you will deadlock or have queries that get committed unexpectedly. Maybe there's a better way to document this somewhere.
I think Mojo::Pg
should check connections that returns into cache. If connection has changed options
or search_path
then Mojo::Pg
should drop connection. Otherwise, the cache can contain connections with different options
or search_path
and cause various unexpected behaviors.
Steps to reproduce the behavior
Expected behavior
All
update
commands will be completed.Actual behavior
The last
update
command is blocked by a previousupdate
, because previousupdate
was run in transaction withAutoCommit = 0
.I know that using expression
$pg->db->begin
incorrectly because of a weakdb
inMojo::Pg::Transaction
. Maybe it should be mention in the documentation? Or maybeMojo::Pg
should not return such connections toqueue
if their attributes has been modified?