Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify database for pg_terminate_backend #93

Merged
merged 1 commit into from
Aug 20, 2016

Conversation

stevenchanin
Copy link
Contributor

@stevenchanin stevenchanin commented Aug 19, 2016

The psql -c \"#{terminate_connection_sql};\" was running without a database specified. Postgres attempts to handle this by connecting to a database with the same name as the current user. If you don't have a database with that name, you get an error:

      executing local: bunzip2 -f db/xyz_production_2016-08-19-121802.sql.bz2 &&  psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'xyz_development' AND pid <> pg_backend_pid();;" ;  dropdb  xyz_development;  createdb  xyz_development;  psql  -d xyz_development < db/xyz_production_201…

psql: FATAL:  database "steven" does not exist

This change supplies the name of a valid database so the terminate_backend command will run without error.

      executing local: bunzip2 -f db/xyz_production_2016-08-19-122005.sql.bz2 &&  psql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'xyz_development' AND pid <> pg_backend_pid();;"  xyz_development;  dropdb  xyz_development;  createdb  xyz_development;  psql  -d xyz_development < db/di…
 pg_terminate_backend
----------------------
(0 rows)

Closes #84

@numbata
Copy link
Collaborator

numbata commented Aug 20, 2016

👍

@numbata numbata merged commit 81b3553 into sgruhier:master Aug 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants