Last active
August 29, 2015 14:05
-
-
Save yingted/587ec761c20d4d201e35 to your computer and use it in GitHub Desktop.
heroku postgresql waiting connections
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
waiter_list() { | |
hk psql -a r101-cedar -c "SELECT * FROM pg_stat_activity WHERE extract(epoch from now() - xact_start) > 60 * 10 AND state = 'idle in transaction'" | |
} | |
waiter_cancel() { | |
hk psql -a r101-cedar -c "SELECT pid, pg_cancel_backend(pid) FROM pg_stat_activity WHERE extract(epoch from now() - xact_start) > 60 * 10 AND state = 'idle in transaction'" | |
} | |
waiter_terminate() { | |
hk psql -a r101-cedar -c "SELECT pid, pg_terminate_backend(pid) FROM pg_stat_activity WHERE extract(epoch from now() - xact_start) > 60 * 30 AND state = 'idle in transaction'" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment