Forcing postgres instance to stop with kill $PG_PID
causes it to log a message received smart shutdown request
and then it does nothin until all the client connections are terminated. Only after that postgres preparing all the resource before the shutdown and exits.
What is the power way on the client side to detect a smart shutdown
event to release all the connections to make pg be able complete the process.
Thank you
You try to connect, and if you get the error message
FATAL: the database system is shutting down
with SQLSTATE 57P03, you know that the server is shutting down. If that state lasts longer than a checkpoint takes, it must be a smart shutdown.