PostgreSQL hangs during shut down in linux?

I m using PostgreSQL 9.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?


Solution 1:

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.

For Debian (pg_ctl is not by default on $PATH):

pg_ctlcluster 9.4 main restart -m fast

Solution 2:

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.