Text Size: Normal / Large

3.6. Shutting Down the Server

There are several ways to shut down the database server. You control the type of shutdown by sending different signals to the server process.

SIGTERM

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 normally. This is Smart Shutdown.

SIGINT

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. This is Fast Shutdown.

SIGQUIT

This is Immediate Shutdown, which will cause the postmaster to send a SIGQUIT to all backends and exit immediately (without properly shutting itself down). 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.

Important: It is best not to use SIGKILL to shut down the postmaster. This will prevent the postmaster from releasing shared memory and semaphores, which may then have to be done by manually.

The PID of the postmaster process can be found using the ps program, or from the file postmaster.pid in the data directory. So for example, to do a fast shutdown:

$ kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`

The program pg_ctl is a shell script that provides a more convenient interface for shutting down the postmaster.


User Comments


joe blow <blue AT example.com>
14 Oct 2003 21:55:28

You can also shut down individual postgres processes with SIGINT and SIGTERM without killing the whole database.

Sending SIGINT will break the current transaction and close the connection, if a transaction is taking place. If a transaction is not taking place, nothing happens.

Sending SIGTERM will break the current transaction, if any, and close the connection.

I couldn\'t find these documented anywhere else. I learned about SIGINT from a newsgroup posting and SIGTERM was just a lucky guess.

Add Comment

Please use this form to add your own comments regarding your experience with particular features of PostgreSQL, clarifications of the documentation, or hints for other users. Please note, this is not a support forum, and your IP address will be logged. If you have a question or need help, please see the faq, try a mailing list, or join us on IRC. Note that submissions containing URLs or other keywords commonly found in 'spam' comments may be silently discarded. Please contact the webmaster if you think this is happening to you in error.

In order to submit a comment, you must have a community account.

* Comment
 

* denotes required field

Privacy Policy | Project hosted by hub.org | Designed by tinysofa
Copyright © 1996 – 2007 PostgreSQL Global Development Group