Fix segmentation fault that commit ac22929a26 caused.

Commit ac22929a26 changed recoveryWakeupLatch so that it's reset to
NULL at the end of recovery. This change could cause a segmentation fault
in the buildfarm member 'elver'.

Previously the latch was reset to NULL after calling ShutdownWalRcv().
But there could be a window between ShutdownWalRcv() and the actual
exit of walreceiver. If walreceiver set the latch during that window,
the segmentation fault could happen.

To fix the issue, this commit changes walreceiver so that it sets
the latch only when the latch has not been reset to NULL yet.

Author: Fujii Masao
Discussion: https://postgr.es/m/5c1f8a85-747c-7bf9-241e-dd467d8a3586@iki.fi
This commit is contained in:
Fujii Masao 2020-11-04 21:49:00 +09:00
parent 560564d3ad
commit 113d3591b8

View File

@ -12673,7 +12673,8 @@ CheckPromoteSignal(void)
void
WakeupRecovery(void)
{
SetLatch(XLogCtl->recoveryWakeupLatch);
if (XLogCtl->recoveryWakeupLatch)
SetLatch(XLogCtl->recoveryWakeupLatch);
}
/*