Re: walwriter interacts quite badly with synchronous_commit=off - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: walwriter interacts quite badly with synchronous_commit=off
Date
Msg-id f868ce06-7445-4b8b-abf6-3847e0fc12a1@iki.fi
Whole thread Raw
In response to Re: walwriter interacts quite badly with synchronous_commit=off  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On 25/10/2023 21:59, Andres Freund wrote:
> On 2023-10-25 12:17:03 +0300, Heikki Linnakangas wrote:
>> On 25/10/2023 02:09, Andres Freund wrote:
>>> Because of the inherent delay between the checks of XLogCtl->WalWriterSleeping
>>> and Latch->is_set, we also sometimes end up with multiple processes signalling
>>> walwriter, which can be bad, because it increases the likelihood that some of
>>> the signals may be received when we are already holding WALWriteLock, delaying
>>> its release...
>>
>> That can only happen when walwriter has just come out of "hibernation", ie.
>> when the system has been idle for a while. So probably not a big deal in
>> practice.
> 
> Maybe I am missing something here - why can this only happen when hibernating?
> Even outside of that two backends can decide that that they need to wake up
> walwriter?

Ah sure, multiple backends can decide to wake up walwriter at the same 
time. I thought you meant that the window for that was somehow wider 
when XLogCtl->WalWriterSleeping.

> We could prevent that, by updating state when requesting walwriter to be woken
> up. But with the changes we're discussing below, that should be rare.

One small easy thing we could do to reduce the redundant wakeups: only 
wake up walwriter if asyncXactLSN points to different page than 
prevAsyncXactLSN.

-- 
Heikki Linnakangas
Neon (https://neon.tech)




pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Remove dead code in pg_ctl.c
Next
From: Jeff Davis
Date:
Subject: Re: doc: a small improvement about pg_am description