Created
February 1, 2018 19:14
-
-
Save vahanNasibyan/37f7fd57811e1aaa0af0344cf4953935 to your computer and use it in GitHub Desktop.
Remove all blocking lock from Postgresql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//view all blocking locks | |
SELECT | |
* | |
FROM | |
pg_locks pl | |
LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid | |
WHERE | |
wait_event_type = 'Lock' AND pl.pid <> pg_backend_pid() | |
ORDER BY | |
query_start ASC | |
LIMIT 3000 | |
//Clear all blocking locks | |
SELECT | |
pg_terminate_backend ( pl.pid ) | |
FROM | |
pg_locks pl | |
LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid | |
WHERE | |
wait_event_type = 'Lock' | |
ORDER BY | |
query_start ASC | |
LIMIT 3000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment