Stopping the server in an emergency
If nothing else is working, we may need to stop the server quickly, without caring about disconnecting the clients gently.
Break the glass in case of emergency!
How to do it…
Follow these steps to stop the server:
- The basic command to perform an emergency stop on the server is as follows:
pg_ctl -D datadir stop -m immediate
- On Debian/Ubuntu, you can also use the following command:
pg_ctlcluster 14 main stop -m immediate
As we mentioned in the previous recipe, this is just a wrapper around pg_ctl
. From this example, we can see that it can pass through the -m immediate
option.
In the previous recipe, we saw examples where the systemctl
command was used to stop a server safely; however, this command cannot be used to perform an emergency stop.
How it works…
When you do an immediate stop, all the users have their transactions aborted and all their connections are...