Skip to content

Instantly share code, notes, and snippets.

@yingted
Last active August 29, 2015 14:05
Show Gist options
  • Save yingted/587ec761c20d4d201e35 to your computer and use it in GitHub Desktop.
Save yingted/587ec761c20d4d201e35 to your computer and use it in GitHub Desktop.
heroku postgresql waiting connections
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