skip to Main Content

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?

2

Answers


  1. You should set idle_in_transaction_session_timeout and statement_timeout. Then your blocking session gets killed if it runs too long statements and if it hangs idle in a database transaction.

    Login or Signup to reply.
  2. statement_timeout is alternative = lock_timeout in PostgreSQL:

    Abort any statement that takes more than the specified amount of time.

    For example, SELECT pg_sleep(30); is timed out after 10 seconds as shown below:

    postgres=# SET statement_timeout to 10000;
    SET
    postgres=# SELECT pg_sleep(30);
    ERROR:  canceling statement due to statement timeout
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search