pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Chris Wilson <chris+google@qwirx.com>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: Pg Docs <pgsql-docs@lists.postgresql.org>
Subject: Re: What does "[backends] should seldom or never need to wait for a write to occur" mean?
Date: Mon, 9 Nov 2020 20:36:32 -0500
Message-ID: <20201110013632.GA8789@momjian.us> (raw)
In-Reply-To: <CAOg7f80WL7cR1TgXXCzzXYcNtfjgAkkc+zXr9T9tshy8jBSZLw@mail.gmail.com>
References: <160399562040.7809.7335281028960123489@wrigleys.postgresql.org>
	<CA+hUKGJG-4huRapjPL7kBXAd+iBW5i09WKgWOFF6E31z_aHkmQ@mail.gmail.com>
	<CAOg7f8272Om2sEM8H0u8u9weVX6NTJNrZqv_FqaRBXmBEQY9aQ@mail.gmail.com>
	<CAOg7f80WL7cR1TgXXCzzXYcNtfjgAkkc+zXr9T9tshy8jBSZLw@mail.gmail.com>

On Tue, Nov  3, 2020 at 06:11:21PM +0000, Chris Wilson wrote:
> Hi all,
> 
> I did some more research and found this explanation in a presentation by
> 2ndQuadrant:
> 
> 
>     When a process wants a buffer, it asks BufferAlloc for the file/block. If
>     the block is already cached, it gets pinned and then returned. Otherwise, a
>     new buffer must be found to hold this data. If there are no buffers free
>     (there usually aren’t) BufferAlloc selects a buffer to evict to make space
>     for the new one. If that page is dirty, it is written out to disk. This can
>     cause the backend trying to allocate that buffer to block as it waits for
>     that write I/O to complete.
> 
> 
> So it seems that both reads and writes can potentially have to wait for I/O.
> And the bgwriter reduces the risk of hitting a dirty page and needing to write
> it before evicting.
> 
> So perhaps the documentation should say:
> 
> "There is a separate server process called the background writer, whose
> function is to issue writes of “dirty” (new or modified) shared buffers.
> This reduces the chances that a backend needing an empty buffer must write a
> dirty one back to disk before evicting it."

I think this would be a step backward.  The point is to say that writes
rarely happen in the foreground, not to explain when writes do happen. 
With your wording, there could be other cases where writes happen in the
foreground, and the point is they rarely happen.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee






view thread (14+ messages)  latest in thread

Message-ID: <20201110013632.GA8789@momjian.us>
Permalink:  ../20201110013632.GA8789@momjian.us/
Also on:    postgresql.org/message-id/20201110013632.GA8789@momjian.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: bruce@momjian.us, chris+google@qwirx.com, thomas.munro@gmail.com, pgsql-docs@lists.postgresql.org
  Subject: Re: What does "[backends] should seldom or never need to wait for a write to occur" mean?
  In-Reply-To: <20201110013632.GA8789@momjian.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox