The following bug has been logged on the website:
Bug reference: 16785
Logged by: John Thompson
Email address: jthompson@maxmind.com
PostgreSQL version: 12.5
Operating system: Ubuntu Linux
Description:
We use pg_prewarm via shared_preload_libraries and we've noticed that if we
start Pg then stop it again before pg_prewarm finishes its initial
prewarming, Pg gets stuck in shutdown until we kill the 'autoprewarm master'
process with 'kill -9'. Removing pg_prewarm from shared_preload_libraries
allows Pg to stop without issue. Also, if we start Pg, wait for 'autoprewarm
successfully prewarmed XXXXXX of YYYYYY previously-loaded blocks' to appear
in the logs, then stop, it shuts down as expected.
This is happening on several different servers, but the one I've been
testing on has 855569 lines in
/var/lib/postgresql/12/main/autoprewarm.blocks, 32GB of RAM, and
shared_buffers is 8028MB.
We're using the 12.5 packages from apt.postgresql.org. Normally we use
systemd to start and stop services, but here's an example with just
pg_ctl:
$ sudo -u postgres /usr/lib/postgresql/12/bin/pg_ctl start -D
/var/lib/postgresql/12/main -l /var/log/postgresql/postgresql-12-main.log -o
'-c config_file="/etc/postgresql/12/main/postgresql.conf"'
waiting for server to start.... done
server started
$ sudo -u postgres /usr/lib/postgresql/12/bin/pg_ctl stop -s -w -D
/var/lib/postgresql/12/main -m fast
pg_ctl: server does not shut down
$ ps auxwww | grep ^postgres
postgres 448 0.7 0.7 8667168 240252 ? Ss 21:10 0:01
/usr/lib/postgresql/12/bin/postgres -D /var/lib/postgresql/12/main -c
config_file=/etc/postgresql/12/main/postgresql.conf
postgres 455 0.1 0.0 182036 4252 ? Ss 21:10 0:00 postgres:
logger
postgres 458 0.0 0.0 8666132 4088 ? Ss 21:10 0:00 postgres:
checkpointer
postgres 462 0.0 0.0 185232 5928 ? Ss 21:10 0:00 postgres:
stats collector
postgres 463 0.3 0.0 8682976 22740 ? Ss 21:10 0:00 postgres:
autoprewarm master
postgres 507 0.0 0.0 8667996 12616 ? Ss 21:10 0:00 postgres:
walsender repmgr 10.150.0.16(33718) streaming 34A65/4243A5C8
postgres 508 0.0 0.0 8667996 12612 ? Ss 21:10 0:00 postgres:
walsender repmgr 10.150.0.15(52982) streaming 34A65/4243A5C8
$ sudo kill 463 -9
$ ps auxwww | grep ^postgres
$
Please let me know if any other information would be useful, I'm happy to
help. Thanks for any help you can offer.