From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: kevent latch paths don't handle postmaster death well
Date: Wed, 14 Oct 2020 18:57:22 -0400
Message-ID: <3637798.1602716242@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+hUKG+z9NtH8j7JLfX-issbQHUb5vCWw+aEpmxxEZ6=mV-Wjg@mail.gmail.com>
References: <3624029.1602701929@sss.pgh.pa.us>
<CA+hUKGKvy_o=gXkbDEnpmJL-PcihAv272v-R+tpX3SdA+NdGVg@mail.gmail.com>
<3625898.1602704431@sss.pgh.pa.us>
<CA+hUKGJ8aHjyxccsn3z4NOpnWBdfUSmzVPm6uc_B63ODnQvvPA@mail.gmail.com>
<3636130.1602713933@sss.pgh.pa.us>
<CA+hUKG+z9NtH8j7JLfX-issbQHUb5vCWw+aEpmxxEZ6=mV-Wjg@mail.gmail.com>
Thomas Munro <thomas.munro@gmail.com> writes:
> (Hmm, I wonder about that Windows process exit event.)
If anyone wants to test that, I can save you a little time building
infrastructure, perhaps. I used the attached program built into a .so.
After creating the function, invoke it, and once it's blocked kill -9
the postmaster. If it successfully reports multiple WL_POSTMASTER_DEATH
results then it's good.
regards, tom lane
Attachments:checkpmdeath.c (text/x-c, 781B) download
/*
create function wait_on_process_latch() returns void
strict volatile language c as '.../whatever.so';
select wait_on_process_latch();
*/
#include "postgres.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "storage/latch.h"
#include "pgstat.h"
PG_MODULE_MAGIC;
/*
* wait_on_process_latch() returns void
*/
PG_FUNCTION_INFO_V1(wait_on_process_latch);
Datum
wait_on_process_latch(PG_FUNCTION_ARGS)
{
int count = 10;
while (count-- > 0)
{
int rc;
CHECK_FOR_INTERRUPTS();
elog(INFO, "waiting on latch");
rc = WaitLatch(MyLatch,
WL_LATCH_SET | WL_POSTMASTER_DEATH, 0,
WAIT_EVENT_BGWORKER_SHUTDOWN);
if (rc & WL_POSTMASTER_DEATH)
{
elog(INFO, "got WL_POSTMASTER_DEATH report");
}
ResetLatch(MyLatch);
}
PG_RETURN_VOID();
}
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-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, thomas.munro@gmail.com, hlinnaka@iki.fi
Subject: Re: kevent latch paths don't handle postmaster death well
In-Reply-To: <3637798.1602716242@sss.pgh.pa.us>
References: <3624029.1602701929@sss.pgh.pa.us> <CA+hUKGKvy_o=gXkbDEnpmJL-PcihAv272v-R+tpX3SdA+NdGVg@mail.gmail.com> <3625898.1602704431@sss.pgh.pa.us> <CA+hUKGJ8aHjyxccsn3z4NOpnWBdfUSmzVPm6uc_B63ODnQvvPA@mail.gmail.com> <3636130.1602713933@sss.pgh.pa.us> <CA+hUKG+z9NtH8j7JLfX-issbQHUb5vCWw+aEpmxxEZ6=mV-Wjg@mail.gmail.com> <3637798.1602716242@sss.pgh.pa.us>
* 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