Re: Maximum number of WAL files in the pg_xlog directory

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Guillaume Lelarge <guillaume(at)lelarge(dot)info>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: Maximum number of WAL files in the pg_xlog directory
Date: 2014-10-14 17:21:53
Message-ID: 20141014172153.GC12170@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 14, 2014 at 09:20:22AM -0700, Jeff Janes wrote:
> On Mon, Oct 13, 2014 at 12:11 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
>
> I looked into this, and came up with more questions.  Why is
> checkpoint_completion_target involved in the total number of WAL
> segments?  If checkpoint_completion_target is 0.5 (the default), the
> calculation is:
>
>         (2 + 0.5) * checkpoint_segments + 1
>
> while if it is 0.9, it is:
>
>         (2 + 0.9) * checkpoint_segments + 1
>
> Is this trying to estimate how many WAL files are going to be created
> during the checkpoint?  If so, wouldn't it be (1 +
> checkpoint_completion_target), not "2 +".  My logic is you have the old
> WAL files being checkpointed (that's the "1"), plus you have new WAL
> files being created during the checkpoint, which would be
> checkpoint_completion_target * checkpoint_segments, plus one for the
> current WAL file.
>
>
> WAL is not eligible to be recycled until there have been 2 successful
> checkpoints.
>
> So at the end of a checkpoint, you have 1 cycle of WAL which has just become
> eligible for recycling,
> 1 cycle of WAL which is now expendable but which is kept anyway, and
> checkpoint_completion_target worth of WAL which has occurred while the
> checkpoint was occurring and is still needed for crash recovery.

OK, so based on this analysis, what is the right calculation? This?

(1 + checkpoint_completion_target) * checkpoint_segments + 1 +
max(wal_keep_segments, checkpoint_segments)

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-10-14 17:24:34 Re: pg_background (and more parallelism infrastructure patches)
Previous Message Stephen Frost 2014-10-14 17:21:45 Re: Buffer Requests Trace