Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TafWB-0005Br-FW for pgsql-bugs@postgresql.org; Tue, 20 Nov 2012 04:33:03 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TafW8-0005KK-13 for pgsql-bugs@postgresql.org; Tue, 20 Nov 2012 04:33:02 +0000 Received: from 172.24.2.119 (EHLO szxeml208-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id ATB29881; Tue, 20 Nov 2012 12:32:56 +0800 (CST) Received: from SZXEML444-HUB.china.huawei.com (10.82.67.182) by szxeml208-edg.china.huawei.com (172.24.2.57) with Microsoft SMTP Server (TLS) id 14.1.323.3; Tue, 20 Nov 2012 12:32:05 +0800 Received: from blrprnc07ns (10.18.96.96) by szxeml444-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.1.323.3; Tue, 20 Nov 2012 12:32:02 +0800 From: Hari Babu To: "'Tom Lane'" CC: References: <10253.1353353527@sss.pgh.pa.us> In-Reply-To: <10253.1353353527@sss.pgh.pa.us> Subject: Re: BUG #7643: Issuing a shutdown request while server startup leads to server hang Date: Tue, 20 Nov 2012 10:01:59 +0530 Message-ID: <005201cdc6d7$fb988f00$f2c9ad00$@kommi@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Ac3GjJFbgd3VoVZITnGBLJGu9HK2lwARbepw Content-Language: en-us X-Originating-IP: [10.18.96.96] X-CFilter-Loop: Reflected X-Pg-Spam-Score: -3.6 (---) X-Archive-Number: 201211/150 X-Sequence-Number: 34708 >haribabu.kommi@huawei.com writes: > Problem Reproduction: > 1. Add recovery.conf to the database directory. > 2. Start the server > 3. Issue the shutdown request > and the shutdown request timing should be such that below server logs should > print. > Log: > ./postgres -D data -p 3335 > LOG: database system was shut down in recovery at 2012-11-08 19:42:42 IST > LOG: entering standby mode > LOG: received fast shutdown request > LOG: consistent recovery state reached at 0/17D0700 > LOG: record with zero length at 0/17D0700 > Problem reproduced in 9.3 head. >After further investigation, I can't reproduce this and I don't believe >your patch fixes it. What happens when I try this is >* postmaster gets SIGINT, sends SIGTERM to startup process >* startup process exits with exit(1) >* postmaster sees that as a startup crash and exits, per the first >test in reaper() >So the log trace I'm getting looks like >LOG: received fast shutdown request >LOG: startup process (PID 9772) exited with exit code 1 >LOG: aborting startup due to startup process failure >Now, transitioning to PM_WAIT_BACKENDS state earlier, as your patch >proposes, might make the log look a bit nicer because the logic in >reaper() wouldn't think the exit was a "crash". But it's not going to >have anything to do with whether the startup process exits on the signal >or not. What seems to have happened for you is that the startup process >ignored the SIGTERM signal, but it's not at all obvious why. >We're going to need more details about how to reproduce this. >I speculate it might have something to do with the specific >restore_command you're using. The problem occurs only when active server is restarting by just adding a recovery.conf file to the data directory. No need of specifying any restore command. or the standby server restart also can lead to this problem. The startup process sends "PMSIGNAL_RECOVERY_STARTED" to postmaster only incase of "InArchiveRecovery" flag is enabled. The SIGINT signal should reach postmaster before the "PMSIGNAL_RECOVERY_STARTED" sent by the startup process. with the following code change in the startupXlog function, the issue can reproduce very easily. if (InArchiveRecovery && IsUnderPostmaster) { PublishStartupProcessInformation(); SetForwardFsyncRequests(); kill (PostmasterPid, SIGINT); SendPostmasterSignal(PMSIGNAL_RECOVERY_STARTED); bgwriterLaunched = true; } Please let me know if I miss anything. Regards, Hari babu.