From: Hari Babu <haribabu.kommi@huawei.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #7643: Issuing a shutdown request while server startup leads to server hang
Date: Mon, 19 Nov 2012 19:58:31 +0530
Message-ID: <007501cdc662$27066e80$75134b80$@kommi@huawei.com> (raw)
For defect 7643 which is described in the following mail,
http://archives.postgresql.org/message-id/E1TWWd4-0008AD-9E@wrigleys.postgre
sql.org
The problem identified as the postmaster handling SIGUSR1 after SIGINT
signal leads to the problem as
bgwriter process is not signaled to terminate by the postmaster as it was
not exist during the processing of
SIGINT signal and after that during the processing of SIGUSR1 signal the
process got created.
As the postmaster is waiting for the bgwriter process to terminate in the
further shutdown follow leads the postmaster process to wait until the
Bgwriter process stops, which enters into a deadlock.
The issue is occurring only incase of SIGINT signal and it was handled for
SIGTERM signal as during the processing of
SIGTERM signal the pmState is modified which blocks the further start of
bgwriter.
The following patch handles the SIGINT signal also the same way as the
SIGTERM signal for the pmState.
inline patch 1: src/backend/postmaster/postmaster.c (+0/-2 lines) download inline-1.patch*** a/src/backend/postmaster/postmaster.c
--- b/src/backend/postmaster/postmaster.c
***************
*** 2258,2270 **** pmdie(SIGNAL_ARGS)
signal_child(BgWriterPID, SIGTERM);
if (WalReceiverPID != 0)
signal_child(WalReceiverPID, SIGTERM);
! if (pmState == PM_RECOVERY)
{
- /* - * Only startup, bgwriter, andcheckpointer should be active
- * in this state; we just signaled the
first two, and we don't
- * want to kill checkpointer yet.
- */
pmState = PM_WAIT_BACKENDS;
}
else if (pmState == PM_RUN ||
--- 2258,2277 ----
signal_child(BgWriterPID, SIGTERM);
if (WalReceiverPID != 0)
signal_child(WalReceiverPID, SIGTERM);
!
! /*
! * In the case of pmState as PM_STARTUP, to avoid
further startup
! * of bgwriter and checkpointer incase of standby
or in archieve
! * recovery mode because we are already in the
process of handling
! * fast shutdown.
! *
! * In the case of pmState as PM_RECOVERY, only
startup, bgwriter
! * and checkpointer should be active in this
state; we just
! * signaled the first two, and we don't want to
kill checkpointer
! * yet.
! */
! if (pmState == PM_RECOVERY || pmState ==
PM_STARTUP)
{
pmState = PM_WAIT_BACKENDS;
}
else if (pmState == PM_RUN ||
Regards,
Hari babu.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: haribabu.kommi@huawei.com
Subject: Re: BUG #7643: Issuing a shutdown request while server startup leads to server hang
In-Reply-To: <007501cdc662$27066e80$75134b80$@kommi@huawei.com>
References: <007501cdc662$27066e80$75134b80$@kommi@huawei.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox