Types of Shutdown in PostgreSQL
| PostgreSQL Shutdown Type | Oracle | Behavior |
|---|---|---|
| Smart (SIGTERM) | SHUTDOWN NORMAL | The server stops accepting new connections but allows existing sessions to continue running normally. PostgreSQL shuts down only after all active sessions disconnect and their transactions complete successfully. |
| Fast (SIGINT – Default) | SHUTDOWN IMMEDIATE | The server stops accepting new connections and immediately terminates all active sessions. Any uncommitted transactions are rolled back, and PostgreSQL performs a clean shutdown gracefully. |
| Immediate (SIGQUIT) | SHUTDOWN ABORT | The server terminates all processes instantly without performing a proper shutdown. No cleanup or checkpoint occurs, so PostgreSQL performs crash recovery by replaying WAL files during the next startup. |
| Shutdown Type | Signal | Command Example | Behavior |
|---|---|---|---|
| Smart | SIGTERM | pg_ctl stop -D /pgData -m smart | Stops new connections, waits for existing sessions to finish normally, then shuts down. |
| Fast (Default) | SIGINT | pg_ctl stop -D /pgdata -m fast | Stops new connections, terminates active sessions, rolls back uncommitted transactions, and shuts down cleanly. |
| Immediate | SIGQUIT | pg_ctl stop -D /pgdata -m immediate | Stops immediately without proper shutdown. Recovery from WAL files happens during next startup. |
Difference Between Reload and Restart
- When we change server configuration parameters, PostgreSQL needs to read those changes before they become active.
- Reload applies the new configuration without stopping or restarting the database service. Existing connections and database activity continue normally.
- Some configuration parameter changes cannot be applied through reload and will only take effect after a restart.
- Restart stops the PostgreSQL server gracefully, ends all running activities, releases resources, closes open files, and then starts the server again with the new configuration.
Smart Shutdown (SIGTERM):
[postgres@pgdb02 ~]$ pg_ctl stop -D /pgData/pgsql17/data -m smart
waiting for server to shut down.... done
server stopped
[postgres@pgdb02 ~]$
2026-07-03 14:26:59.741 +08 [3476] LOG: received smart shutdown request
2026-07-03 14:26:59.752 +08 [3476] LOG: background worker "logical replication launcher" (PID 3483) exited with exit code 1
2026-07-03 14:26:59.753 +08 [3478] LOG: shutting down
2026-07-03 14:26:59.755 +08 [3478] LOG: checkpoint starting: shutdown immediate
2026-07-03 14:26:59.765 +08 [3478] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.003 s, total=0.012 s; sync files=2, longest=0.003 s, average=0.002 s; distance=0 kB, estimate=0 kB; lsn=1/105465F0, redo lsn=1/105465F0
2026-07-03 14:26:59.771 +08 [3476] LOG: database system is shut down
[postgres@pgdb02 ~]$ pg_ctl start -D /pgData/pgsql17/data
waiting for server to start....2026-07-03 14:27:18.394 +08 [3487] LOG: redirecting log output to logging collector process
2026-07-03 14:27:18.394 +08 [3487] HINT: Future log output will appear in directory "log".
done
server started
[postgres@pgdb02 ~]$
2026-07-03 14:27:18.394 +08 [3487] LOG: starting PostgreSQL 17.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-14), 64-bit
2026-07-03 14:27:18.396 +08 [3487] LOG: listening on IPv4 address "0.0.0.0", port 5432
2026-07-03 14:27:18.396 +08 [3487] LOG: listening on IPv6 address "::", port 5432
2026-07-03 14:27:18.399 +08 [3487] LOG: listening on Unix socket "/run/postgresql/.s.PGSQL.5432"
2026-07-03 14:27:18.404 +08 [3487] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2026-07-03 14:27:18.413 +08 [3491] LOG: database system was shut down at 2026-07-03 14:26:59 +08
2026-07-03 14:27:18.425 +08 [3487] LOG: database system is ready to accept connections
Fast Shutdown (SIGINT – Default):
[postgres@pgdb02 ~]$ pg_ctl stop -D /pgData/pgsql17/data -m fast
waiting for server to shut down.... done
server stopped
[postgres@pgdb02 ~]$
2026-07-03 14:28:26.839 +08 [3487] LOG: received fast shutdown request
2026-07-03 14:28:26.844 +08 [3487] LOG: aborting any active transactions
2026-07-03 14:28:26.854 +08 [3487] LOG: background worker "logical replication launcher" (PID 3494) exited with exit code 1
2026-07-03 14:28:26.860 +08 [3489] LOG: shutting down
2026-07-03 14:28:26.862 +08 [3489] LOG: checkpoint starting: shutdown immediate
2026-07-03 14:28:26.874 +08 [3489] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.005 s, total=0.015 s; sync files=2, longest=0.004 s, average=0.003 s; distance=0 kB, estimate=0 kB; lsn=1/105466A0, redo lsn=1/105466A0
2026-07-03 14:28:26.882 +08 [3487] LOG: database system is shut down
[postgres@pgdb02 ~]$ pg_ctl start -D /pgData/pgsql17/data
waiting for server to start....2026-07-03 14:29:00.574 +08 [3505] LOG: redirecting log output to logging collector process
2026-07-03 14:29:00.574 +08 [3505] HINT: Future log output will appear in directory "log".
done
server started
[postgres@pgdb02 ~]$
2026-07-03 14:29:00.575 +08 [3505] LOG: starting PostgreSQL 17.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-14), 64-bit
2026-07-03 14:29:00.579 +08 [3505] LOG: listening on IPv4 address "0.0.0.0", port 5432
2026-07-03 14:29:00.580 +08 [3505] LOG: listening on IPv6 address "::", port 5432
2026-07-03 14:29:00.582 +08 [3505] LOG: listening on Unix socket "/run/postgresql/.s.PGSQL.5432"
2026-07-03 14:29:00.587 +08 [3505] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2026-07-03 14:29:00.595 +08 [3509] LOG: database system was shut down at 2026-07-03 14:28:26 +08
2026-07-03 14:29:00.607 +08 [3505] LOG: database system is ready to accept connections
Immediate Shutdown (SIGQUIT):
[postgres@pgdb02 ~]$ pg_ctl stop -D /pgData/pgsql17/data -m immediate
waiting for server to shut down.... done
server stopped
[postgres@pgdb02 ~]$
2026-07-03 14:29:47.471 +08 [3505] LOG: received immediate shutdown request
2026-07-03 14:29:47.485 +08 [3505] LOG: database system is shut down
[postgres@pgdb02 ~]$ pg_ctl start -D /pgData/pgsql17/data
waiting for server to start....2026-07-03 14:30:17.965 +08 [3520] LOG: redirecting log output to logging collector process
2026-07-03 14:30:17.965 +08 [3520] HINT: Future log output will appear in directory "log".
. done
server started
[postgres@pgdb02 ~]$
2026-07-03 14:30:17.966 +08 [3520] LOG: starting PostgreSQL 17.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-14), 64-bit
2026-07-03 14:30:17.966 +08 [3520] LOG: listening on IPv4 address "0.0.0.0", port 5432
2026-07-03 14:30:17.966 +08 [3520] LOG: listening on IPv6 address "::", port 5432
2026-07-03 14:30:17.970 +08 [3520] LOG: listening on Unix socket "/run/postgresql/.s.PGSQL.5432"
2026-07-03 14:30:17.974 +08 [3520] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2026-07-03 14:30:17.983 +08 [3524] LOG: database system was interrupted; last known up at 2026-07-03 14:29:00 +08
2026-07-03 14:30:19.211 +08 [3524] LOG: database system was not properly shut down; automatic recovery in progress
2026-07-03 14:30:19.216 +08 [3524] LOG: redo starts at 1/10546718
2026-07-03 14:30:19.216 +08 [3524] LOG: invalid record length at 1/10546750: expected at least 24, got 0
2026-07-03 14:30:19.217 +08 [3524] LOG: redo done at 1/10546718 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2026-07-03 14:30:19.221 +08 [3522] LOG: checkpoint starting: end-of-recovery immediate wait
2026-07-03 14:30:19.231 +08 [3522] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.003 s, total=0.012 s; sync files=2, longest=0.002 s, average=0.002 s; distance=0 kB, estimate=0 kB; lsn=1/10546750, redo lsn=1/10546750
2026-07-03 14:30:19.239 +08 [3520] LOG: database system is ready to accept connections
Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.
Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/