Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I m using PostgreSQL9.0. It hangs during shutdown. when I used ---pg_ctl stop it hangs and after sometime its displaying msg--- pg_ctl: server does not shut down

and when I used psql its showing----psql: FATAL: the database system is shutting down

and in logs its writing these msgs

DEBUG: postmaster received signal 15 2011-07-14 09:36:00 ETC/GMT LOG: received smart shutdown request

Please tell me how to resolve it???

share|improve this question

migrated from stackoverflow.com Jul 14 '11 at 12:23

This question came from our site for professional and enthusiast programmers.

    
Which distribution of GNU/Linux you have ? @Magnus is right about smart and fast shutdown. You might read more about it in doc (postgresql.org/docs/current/static/server-shutdown.html). It's pretty well explained there. –  Grzegorz Szpetkowski Jul 14 '11 at 10:07

4 Answers 4

A regular shutdown request will wait until all connections are terminated.

When pg_ctl stop "hangs", it means you still have open connections to the database. Shut down all applications that connect to that server and then Postgres should shut down normally.

The error "the database system is shutting down" comes from the fact that Postgres is trying to shutdown and thereofor does not allow any new connections.

share|improve this answer

When trying to identify what's going on, you can log in via psql and type:

test=> SELECT * FROM pg_stat_activity;
 datid | datname | procpid | usesysid |   usename    | application_name | client_addr | client_hostname | client_port |         backend_start         |          xact_start           |          query_start          | waiting |          current_query          
-------+---------+---------+----------+--------------+------------------+-------------+-----------------+-------------+-------------------------------+-------------------------------+-------------------------------+---------+---------------------------------
 18703 | test |    7604 |    18702 | test_sean | psql             |             |                 |          -1 | 2011-07-14 07:23:40.021921+00 |                               | 2011-07-14 07:23:46.398894+00 | f       | <IDLE>
 18703 | test |    7673 |    18702 | test_sean | psql             |             |                 |          -1 | 2011-07-14 07:24:54.507982+00 | 2011-07-14 07:25:00.102369+00 | 2011-07-14 07:25:00.102369+00 | f       | SELECT * FROM pg_stat_activity;
(2 rows)
share|improve this answer
1  
That's going to be hard, since the system is in shutdown mode... –  Magnus Hagander Jul 14 '11 at 8:35
    
Quite so. The above will at least give the questioner the ability to dig in at some point in the future. –  Sean Jul 15 '11 at 16:28

By default, pg_ctl will attempt a "smart shutdown". This shutdown will tell the system not to accept any new connections, but not shut down until existing ones have disconnected.

You probably want to use "fast" shutdown (by executing pg_ctl -m fast), which will also disconnect existing users.

share|improve this answer

Unless you absolutely want to use pg_ctl, why not use the following instead :

sudo /etc/init.d/postgresql-9.1 stop

The init.d scripts issues :

$SU -l postgres -c "$PGENGINE/pg_ctl stop -D '$PGDATA' -s -m fast" > /dev/null 2>&1 < /dev/null

This is a fast shutdown and performs what you need.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.