Skip site navigation (1) Skip section navigation (2)

Re: formula about the number of WAL files

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: pgsql-docs <pgsql-docs(at)postgresql(dot)org>
Subject: Re: formula about the number of WAL files
Date: 2010-10-15 10:44:24
Message-ID: AANLkTi=e=oR54OuxAw88=dtV4wt0e5edMiGaeZtBVcKO@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-docs
On Fri, Oct 15, 2010 at 6:19 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> On Thu, 2010-10-14 at 12:00 +0900, Fujii Masao wrote:
>> ----------------
>> 29.4. WAL Configuration
>>
>> There will always be at least one WAL segment file, and will normally not
>> be more than (2 + checkpoint_completion_target) * checkpoint_segments + 1
>> or checkpoint_segments + wal_keep_segments + 1 files.
>> ----------------
>>
>> The above formula is wrong. The correct is
>>
>>     (2 + checkpoint_completion_target) * checkpoint_segments +
>> wal_keep_segments + 1
>>
>> The attached patch fixes this fault.
>
> The current docs are wrong, but your re-definition doesn't match the
> actual code in CreateCheckPoint().
>
> I've updated the docs to reflect how the code behaves.

Hmm.. I seem to be very mixed up. Let me consider the formula again.


Basically checkpoint deletes the WAL files which are older than
the prior checkpoint's redo location. So at least WAL files which
were generated from the prior ckpt start to current ckpt end can
exist in pg_xlog directory. The number of those WAL files is

    (1 + checkpoint_completion_target) * checkpoint_segments

But if this number is smaller than wal_keep_segments, checkpoint
leaves wal_keep_segments WAL files in pg_xlog instead. So, from
this aspect, the maximum number of WAL files in pg_xlog is

    (1 + checkpoint_completion_target) * checkpoint_segments

    or

    wal_keep_segments

After checkpoint deletes old WAL files, the number of WAL files in
pg_xlog continues to increase until subsequent checkpoint will have
deleted WAL files. The increased number is

    checkpoint_segments

Furthermore, one WAL file might be preallocated aside from the above.

As the result of the above, the maximum number of WAL files in
pg_xlog is

    (2 + checkpoint_completion_target) * checkpoint_segments + 1

    or

    wal_keep_segments + checkpoint_segments + 1

So the original description seems to be correct. Am I missing
something?

# My previous proposal is definitely wrong. Sorry for noise.

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

In response to

Responses

pgsql-docs by date

Next:From: Simon RiggsDate: 2010-10-15 13:48:57
Subject: Re: formula about the number of WAL files
Previous:From: Simon RiggsDate: 2010-10-15 09:20:51
Subject: Re: [HACKERS] Docs for archive_cleanup_command are poor

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group