Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSpiF-0004Ft-Dk for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 22:57:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kSpiD-0007xV-QH for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 22:57:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSpiD-0007xO-JX for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2020 22:57:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSpiB-0005T6-FD for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2020 22:57:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09EMvM2r3637799; Wed, 14 Oct 2020 18:57:22 -0400 From: Tom Lane To: Thomas Munro cc: Heikki Linnakangas , PostgreSQL Hackers Subject: Re: kevent latch paths don't handle postmaster death well In-reply-to: References: <3624029.1602701929@sss.pgh.pa.us> <3625898.1602704431@sss.pgh.pa.us> <3636130.1602713933@sss.pgh.pa.us> Comments: In-reply-to Thomas Munro message dated "Thu, 15 Oct 2020 11:50:18 +1300" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <3637744.1602716167.0@sss.pgh.pa.us> Date: Wed, 14 Oct 2020 18:57:22 -0400 Message-ID: <3637798.1602716242@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3637744.1602716167.1@sss.pgh.pa.us> Thomas Munro 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 ------- =_aaaaaaaaaa0 Content-Type: text/x-c; name="checkpmdeath.c"; charset="us-ascii" Content-ID: <3637744.1602716167.2@sss.pgh.pa.us> Content-Description: checkpmdeath.c /* 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(); } ------- =_aaaaaaaaaa0--