aboutsummaryrefslogtreecommitdiff
path: root/src/backend/postmaster/checkpointer.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2020-04-29 18:46:42 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2020-04-29 18:46:42 -0400
commit1816a1c6ffe46782eee9a16a974b4aa3f4b8457b (patch)
tree0c8c2d8e41d7b7d7a3f038498fa59cc0fbd36e3a /src/backend/postmaster/checkpointer.c
parentfef819ac534d6efb9608fa0bbb93c6fe6c87440e (diff)
downloadpostgresql-1816a1c6ffe46782eee9a16a974b4aa3f4b8457b.tar.gz
postgresql-1816a1c6ffe46782eee9a16a974b4aa3f4b8457b.zip
Fix checkpoint signalling
Checkpointer uses its MyLatch to wake up when a checkpoint request is received. But before commit c6550776394e the latch was not used for anything else, so the code could just go to sleep after each loop without rechecking the sleeping condition. That commit added a separate ResetLatch in its code path[1], which can cause a checkpoint to go unnoticed for potentially a long time. Fix by skipping sleep if any checkpoint flags are set. Also add a test to verify this; authored by Kyotaro Horiguchi. [1] CreateCheckPoint -> InvalidateObsoleteReplicationSlots -> ConditionVariableTimeSleep Report and diagnosis by Kyotaro Horiguchi. Co-authored-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Co-authored-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/20200408.141956.891237856186513376.horikyota.ntt@gmail.com
Diffstat (limited to 'src/backend/postmaster/checkpointer.c')
-rw-r--r--src/backend/postmaster/checkpointer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index e354a78725e..2b552a7ff90 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -495,6 +495,13 @@ CheckpointerMain(void)
pgstat_send_bgwriter();
/*
+ * If any checkpoint flags have been set, redo the loop to handle the
+ * checkpoint without sleeping.
+ */
+ if (((volatile CheckpointerShmemStruct *) CheckpointerShmem)->ckpt_flags)
+ continue;
+
+ /*
* Sleep until we are signaled or it's time for another checkpoint or
* xlog file switch.
*/