From 6f3d2e740d1ef198e938cd28225d0ffcfe127e59 Mon Sep 17 00:00:00 2001 From: Ashwin Agrawal and Abhijit Subramanya Date: Fri, 17 Feb 2017 16:24:57 -0800 Subject: [PATCH] Release locks when exiting from FileRepPrimary_IsMirroringRequired() Commit d09cf2e6424470c3651365df133fcf4177a48871 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 --- src/backend/cdb/cdbfilerepprimary.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/cdb/cdbfilerepprimary.c b/src/backend/cdb/cdbfilerepprimary.c index fc244323b9..1c71d5ee4c 100644 --- a/src/backend/cdb/cdbfilerepprimary.c +++ b/src/backend/cdb/cdbfilerepprimary.c @@ -269,8 +269,15 @@ FileRepPrimary_IsMirroringRequired( 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(); proc_exit(0); } -- GitLab