Re: [GENERAL] Which process is actually doing the WAL writes/calls XLogFlush? - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] Which process is actually doing the WAL writes/calls XLogFlush?
Date
Msg-id CAKFQuwa3W=X8eJ_xCq+vBR6nwugTeemNWkQaR-_-_KwkO8AAEA@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Which process is actually doing the WAL writes/calls XLogFlush?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: [GENERAL] Which process is actually doing the WAL writes/callsXLogFlush?  (Daniel Westermann <daniel.westermann@dbi-services.com>)
List pgsql-general
On Tue, Jun 27, 2017 at 3:52 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 06/27/2017 11:19 AM, Daniel Westermann wrote:
>
> Thanks, Adrian
> It is clear now for the asynchronous stuff and wal_writer.
> But I still did not figure out (or I am just not able to understand it from the README linked above)
> which process is actually doing the write to the wal when you have synchronous commit set to on. Can
> someone put some light on this?

AFAIK the wal writer process.

​Um, no.  "Synchronous" means that the caller has to wait for the result to appear before it can move on.  "Asynchronous" means that the caller can issue the instruction and immediately move on.  I guessing here but while usually the caller would have to provide callback hook to get the answer in the future in this case the caller is assuming a positive result and doesn't listen for a response.  It is for the asynchronous mode ​that wal_writer exists.  In synchronous mode it would be somewhat inefficient to hand-off/leave the work to a separate process to perform while the main process remains idle - better to just have the main process do it.  Its not a total win since the WAL file takes on the inherent contention.

The linked readme (and I suspect much of the docs) was written under the assumption that the calling session performs all work not otherwise explicitly designated as being handled by a separate process.  That is why you cannot find an affirmative answer to the posed question - it is taken as something having been previously learned (or deduced in my case - the others links being illustrative too).

Now, I'm still just going off of human documentation and not the actual code - but my confidence level is quite high.

David J.

pgsql-general by date:

Previous
From: DrakoRod
Date:
Subject: Re: [GENERAL] postgres: dbname dbuser 9.9.9.9[2222] PARSE waiting
Next
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] postgres: dbname dbuser 9.9.9.9[2222] PARSE waiting