bgworker sigusr1 handler - Mailing list pgsql-hackers

From Robert Haas
Subject bgworker sigusr1 handler
Date
Msg-id CA+Tgmob00PsNg4iFb0sR4Mexr2rkdmJWmMh-RL8S8=wCO-PmaQ@mail.gmail.com
Whole thread Raw
Responses Re: bgworker sigusr1 handler
Re: bgworker sigusr1 handler
List pgsql-hackers
Just for fun, I implemented a toy background worker tonight using the
new bgworker framework.  Generally, it went well, and I'm pleased with
the design of the new facility. However, I did notice one oddity.  I
initialized the worker flags like this:
       worker.bgw_flags = BGWORKER_SHMEM_ACCESS;

And... latches didn't work.  It turns out that if you request database
access, then the SIGUSR1 handler is set to procsignal_sigusr1_handler,
which is fine.  But if you don't, it gets set to SIG_IGN.  And the
result of *that* is that if someone sets a latch for which the
background process is waiting, the background process fails to notice.

Now, once you understand what's going on here, it's not hard to work
around.  But it seems to me that it would be a saner default to set
the signal handler to something like the bgwriter handler, which just
calls latch_sigusr1_handler.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Enabling Checksums
Next
From: Amit Kapila
Date:
Subject: Re: Unrecognized type error (postgres 9.1.4)