Tuesday, October 8, 2024

How to check either table has been locked or not AND how to kill the process

 

SELECT

    l.locktype,

    l.mode,

    l.granted,

    l.pid,

    a.query,

    a.state,

    a.query_start

FROM pg_locks l

JOIN pg_stat_activity a ON l.pid = a.pid

WHERE l.relation = 'your_table_name'::regclass;

 

SELECT pg_terminate_backend(4868);

* 4868 is PID (Process ID)

No comments:

Post a Comment