Fix waiting in RegisterSyncRequest().
authorThomas Munro <tmunro@postgresql.org>
Wed, 16 Mar 2022 02:35:16 +0000 (15:35 +1300)
committerThomas Munro <tmunro@postgresql.org>
Wed, 16 Mar 2022 02:35:16 +0000 (15:35 +1300)
commit3390ef1b7be28eac24dd95af23a4a287e6e7b1a4
tree457f498334230a7d9af072c61aa57a8de9673f32
parent076f4d9539e9687d68ada32353c0c16d9bfa3cfb
Fix waiting in RegisterSyncRequest().

If we run out of space in the checkpointer sync request queue (which is
hopefully rare on real systems, but common with very small buffer pool),
we wait for it to drain.  While waiting, we should report that as a wait
event so that users know what is going on, and also handle postmaster
death, since otherwise the loop might never terminate if the
checkpointer has exited.

Back-patch to 12.  Although the problem exists in earlier releases too,
the code is structured differently before 12 so I haven't gone any
further for now, in the absence of field complaints.

Reported-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20220226213942.nb7uvb2pamyu26dj%40alap3.anarazel.de
doc/src/sgml/monitoring.sgml
src/backend/storage/sync/sync.c
src/backend/utils/activity/wait_event.c
src/include/utils/wait_event.h