Checking for Connections

In general, it is not critical that all connections be stopped prior to a promotion as the script will promote in a safe fashion. Ideally, you do want connections associated with background work to wrap up before the promotion so that work does not have to be restarted. These checks are designed to help prevent errors from showing up in the application about the database disconnecting client connections.

When you run the commands below you will see the query associated with your own connection, but generally, when accessing as your application user, should not see any other connections.

For PostgreSQL run the command:

psql -c 'SELECT pid, datname, usename, application_name, client_hostname, waiting, query
FROM pg_stat_activity;'


For MySQL run the command:

mysql -e'show processlist'


If there is any connection with the deploy user, that means there are still running application processes (worker, background jobs, or cron jobs) that are connected to the database. In that case, the application processes should be stopped in advance of the promotion. The ideal output should list only connections with root and replication users.




  • Avatar
    Trevor DeVore

    It isn't clear what I should be looking for in the `mysql -e'show processlist'` output. The article links to this article as a reference for the "Verify that there are no remaining database connections." step.

    I always get the same number of rows with the columns Id, User, Host, db, Command, Time, State, Info, Rows_sent, and Rows_examined. What am I looking for exactly to ensure that there are no remaining database connections?

    Comment actions Permalink
  • Avatar
    Yusuf Nar

    The article was amended accordingly. Thanks a lot for the feedback!

    Edited by Yusuf Nar
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk