BUG #16785: Postgresql shutdown during initial pg_prewarm prewarming causes Pg to get stuck

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: jthompson(at)maxmind(dot)com
Subject: BUG #16785: Postgresql shutdown during initial pg_prewarm prewarming causes Pg to get stuck
Date: 2020-12-21 21:15:24
Message-ID: 16785-c0207d8c67fb5f25@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16785
Logged by: John Thompson
Email address: jthompson(at)maxmind(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-12-22 01:10:59 Re: BUG #16785: Postgresql shutdown during initial pg_prewarm prewarming causes Pg to get stuck
Previous Message Tom Lane 2020-12-21 19:26:06 Re: BUG #16784: Server crash in ExecReScanAgg()