3.7. Temporarily Shutting Down PostgreSQL

Sometimes you want to temporarily stop or restart PostgreSQL to maintain or version up it. In this section how to perform the task with minimum downtime.

Stopping or restarting PostgreSQL causes failover. If the running mode is not streaming replication mode, or the server is a standby server in streaming replication mode, probably that's not a big deal because clients can always use other servers in the cluster. However if the server is primary server, it will cause change of primary server by promoting one of the standby servers. Moreover if there's only one server remains in the cluster, there are no alternative server or standby server which can be promoted.

In this case you can use backend_flag to avoid failover. By setting below in pgpool.conf will avoid failover of backend0.

backend_flag0 = DISALLOW_TO_FAILOVER
    

This will take effect by reloading or restarting Pgpool-II. If this flag is set, failover will not happen if the backend is not available. While the backend is not available, clients wil get error message:

psql: error: could not connect to server: FATAL:  failed to create a backend connection
DETAIL:  executing failover on backend
   

After restarting the backend, clients can connect as usual. To allow failover on the backend again, you can set:

backend_flag0 = ALLOW_TO_FAILOVER
   

and reload or restart Pgpool-II.