We have a web service where all user facing read/write transactions are executed with isolation level SERIALIZABLE. However, we have been having problems where the transaction length of some connections goes through the roof and it seems that in majority (all?) cases the problem has been query ROLLBACK TRANSACTION
. Connections stalling in this state are visible in pg_stat_activity
table.
Unless I've misunderstood something, rolling back a SERIALIZABLE transaction should always be successful without any kinds of locking and should require practically no resources to execute on PostgreSQL.
What could cause SERIALIZABLE transaction to hang on ROLLBACK TRANSACTION
?
We're running connections through pgbouncer
version 1.7 running on localhost
using pool_mode=transaction
in case that makes a difference. Running select pg_terminate_backend(123)
where 123
is the offending connection does not immediately free the query from client's point of view. The client only sees anything 1h after the query and then I get response:
57P01 terminating connection due to administrator command
08P01 server conn crashed?