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
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.
Please sign in to leave a comment.