I need to kill my session, if I’m blocking other sessions.But as of now we have only option to kill own session blocked by other sessions using lock_timeout.
Do we have option in postgres to timeout own session, if our session blocked other sessions not own session blocked by others?
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
2
Answers
You should set
idle_in_transaction_session_timeout
andstatement_timeout
. Then your blocking session gets killed if it runs too long statements and if it hangs idle in a database transaction.statement_timeout is alternative = lock_timeout in PostgreSQL:
For example,
SELECT pg_sleep(30);
is timed out after 10 seconds as shown below: