There are different ways to make a database shutdown for every
database type whether it is MySQL, Oracle, MongoDB, etc, in PostgreSQL as well,
there are 3 types of shutdown based on the signal provided
1.
SIGTERM
2.
SIGINT
3.
SIGQUIT
We will discuss them one by one
SIGTERM
This type of
shutdown is identified as a smart shutdown
After receiving a
shutdown signal, SIGTERM
disallows new connections
let’s existing connection works
normally
shuts down only after sessions
are terminated
If the server is
in online backup mode
It additionally waits
until the online backup mode is no longer active, new connections still are
allowed for superusers only, as they might need to send a request to
disable the are online backup mode
If the server is
in recovery mode
The recovery
process will be stopped only after all regular sessions are terminated.
SIGINT
This mode is
termed fast shutdown mode
once a SIGINT
signal is sent, it
disallows new connections and sends
all existing server processes SIGTERM, which makes them abort respective current
transactions and exit promptly
waits until all server process
to exit and finally shuts down.
if the server is
in online backup mode
the backup mode
will be terminated and the backup will be made useless
SIGQUIT
This mode is
termed immediate shutdown mode
The server will
send SIGQUIT to all the child processes and wait for them to terminate
and if it is not terminated within 5 sec, it sends SIGKILL
After forcing
SIGQUIT,
the database
needs recovery on the next startup
only recommended in case of
emergency.