Re: Reduced power consumption in WAL Writer process - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Reduced power consumption in WAL Writer process
Date
Msg-id CAEYLb_XA9E_RU8On=LBEgkxQPCBUW6VO2SP-nc2Z7rccBX3N6g@mail.gmail.com
Whole thread Raw
In response to Re: Reduced power consumption in WAL Writer process  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Reduced power consumption in WAL Writer process
List pgsql-hackers
This is a bit of a detour, but probably a useful one. Attached is a
patch that replaces a tight PostmasterIsAlive() polling loop in the AV
launcher with a latch, making use of the new WL_POSTMASTER_DEATH
functionality. It's similar to what we've already done for the
archiver. It is relatively straightforward as these auxiliary process
polling loop elimination patches go (certainly compared to what we're
contemplating with the WAL writer), but it raises some questions that
we were lucky to have been able to avoid when I worked on the
archiver. Obviously, this patch isn't finished.

We register various generic signal handlers for the AVLauncher,
including StatementCancelHandler(). Of course, signals that are
handled generically have the same potential to invalidate WaitLatch()
timeout as any other type of signal. We should be mindful of this.

ISTM that these generic handlers ought to be handling this
generically, and that there should be a Latch for just this purpose
for each process within PGPROC. We already have this Latch in PGPROC:

Latch           waitLatch;              /* allow us to wait for sync rep */

Maybe its purpose should be expanded to "current process Latch"?

Another concern is, what happens when we receive a signal, generically
handled or otherwise, and have to SetLatch() to avoid time-out
invalidation? Should we just live with a spurious
AutoVacLauncherMain() iteration, or should we do something like check
if the return value of WaitLatch indicates that we woke up due to a
SetLatch() call, which must have been within a singal handler, and
that we should therefore goto just before WaitLatch() and elide the
spurious iteration? Given that we can expect some signals to occur
relatively frequently, spurious iterations could be a real concern.

Incidentally, should I worry about the timeout long for WaitLatch()
overflowing?

--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services

Attachment

pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: proposal: a validator for configuration files
Next
From: Robert Haas
Date:
Subject: Re: [COMMITTERS] pgsql: Enable CHECK constraints to be declared NOT VALID