Depending on your needs, there are several ways to shut down the database server when your work is done. The results are controlled by which signal you send to the server process.
After receiving SIGTERM, the postmaster disallows new connections, but lets existing backends end their work normally. It shuts down only after all of the backends terminate by client request. This is the Smart Shutdown.
The postmaster disallows new connections and sends all existing backends SIGTERM, which will cause them to abort their current transactions and exit promptly. It then waits for the backends to exit and finally shuts down the database. This is the Fast Shutdown.
This is the Immediate Shutdown, which causes the postmaster to send a SIGQUIT to all backends and exit immediately (without properly shutting down the database). The backends likewise exit immediately upon receiving SIGQUIT. This will lead to recovery (by replaying the WAL log) upon next start-up. This is recommended only in emergencies.
It is best not to use SIGKILL to shut down the postmaster. This prevents the postmaster from releasing shared memory and semaphores, which you may then have to do by hand. |
> kill -INT `head -1 /var/lib/pgsql/data/postmaster.pid` |