Re: max_wal_size - Mailing list pgsql-docs

From p.luzanov@postgrespro.ru
Subject Re: max_wal_size
Date
Msg-id b8e12875ebec9e6d3107df5fa1129e1e@postgrespro.ru
Whole thread Raw
In response to Re: max_wal_size  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: max_wal_size
Re: max_wal_size
List pgsql-docs
David,

I think part of the issue is your operating with a mental model of
this contrary to the one the documentation was written for.

I made this assumption(checkpoints triggered by size, checkpoint_completion_target=1) only for simplifying example.
(Although there is a practical task: calculate the possible approximate size of all WAL files. This is especially important for versions prior to 11, where WAL files were stored for the previous checkpoint.)

In any case "grow to" means that it doesn't matter whether at the end
of the previous checkpoint 1gb or 9gb were in use - once the usage
goes "up to" 10gp the automatic checkpoint will trigger.  If the word
"to" wasn't there your interpretation would be correct.  Its a fair
argument to say such an important distinction shouldn't be placed on
the word "to" but it isn't wrong.

Thank you for an explanation. But give me another chance to explain.

Now we have the glossary. According to the glossary, a checkpoint has two meanings.

The first meaning is that this is a point:
"A point in the WAL sequence at which it is guaranteed that the heap and index data files have been updated with all information from shared memory modified before that checkpoint; a checkpoint record is written and flushed to WAL to mark that point."

Simple illustration:
                A           B           C
WAL |-----------|-----------|-----------|----------->

Points A,B,C are records in the WAL.

The second meaning is that this is an action (performed by checkpointer process or CP):
"A checkpoint is also the act of carrying out all the actions that are necessary to reach a checkpoint as defined above."

Add a process to the illustration. Checkpoint_completion_target here is the default value of 0.5:

                A           B           C
WAL |-----------|-----+-----|-----+-----|-----+----->

                   a           b           c  
CP              +-----+     +-----+     +-----+
                b     e     b     e     b     e

Checkpointer process for point A starts at a(b) and ends at a(e).
At the end of the work, CP makes a WAL record(plus symbol on WAL line).

Back to the max_wal_size description:
"Maximum size to let the WAL grow to between automatic WAL checkpoints."

As I understand now, this is true when we talk about the checkpoint as a process.
"Maximum size to let the WAL grow to between a(b) and b(e), between b(b) and c(e), etc".

But this not true when we talk about the checkpoint as a point.
"Maximum size to let the WAL grow to between A and B".

My concerns that someone reading the description of the parameter may confuse the two meanings of checkpoint: as a point and as a process. After all, this happened to me.

-----
Pavel Luzanov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

pgsql-docs by date:

Previous
From: Thomas Munro
Date:
Subject: Re: wal_init_zero and wal_recycle
Next
From: "David G. Johnston"
Date:
Subject: Re: max_wal_size