Release locks when exiting from FileRepPrimary_IsMirroringRequired()

Commit d09cf2e6 introduced proc_exit(0) based
on the check that postmaster is not alive and the segment is at fault. The
check for postmaster being alive is incorrect when passed true for
`PostmasterIsAlive()` in case of resync worker as resync workers are not direct
children on postmaster. Because of the incorrect check proc_exit(0) is called
always for resync worker when segment is in fault. Also, the locks are not
released while exiting which might cause other backends `StartTransaction()` to
hang due to virtual xact lock.

Fixes #1791
上级 f748ffa8
...@@ -269,8 +269,15 @@ FileRepPrimary_IsMirroringRequired( ...@@ -269,8 +269,15 @@ FileRepPrimary_IsMirroringRequired(
primaryMirrorSetIOSuspended(TRUE); primaryMirrorSetIOSuspended(TRUE);
} }
if (!PostmasterIsAlive(true)) /*
* This code path can be reached from backends which are
* not directly spawned from PostMaster. For e.g the
* FileRepResyncWorker process is spawned by FileRepMain.
* Hence PostmasterIsAlive() needs to be called with false.
*/
if (!PostmasterIsAlive(false))
{ {
LockReleaseAll(DEFAULT_LOCKMETHOD, false);
LWLockReleaseAll(); LWLockReleaseAll();
proc_exit(0); proc_exit(0);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册