Re: [GENERAL] checkpoint clarifications needed - Mailing list pgsql-general

From Adrian Klaver
Subject Re: [GENERAL] checkpoint clarifications needed
Date
Msg-id cbdd3b1d-a670-0761-820f-5a7a1886c8a5@aklaver.com
Whole thread Raw
In response to Re: [GENERAL] checkpoint clarifications needed  (Tom DalPozzo <t.dalpozzo@gmail.com>)
Responses Re: [GENERAL] checkpoint clarifications needed  (Tom DalPozzo <t.dalpozzo@gmail.com>)
List pgsql-general
On 01/09/2017 06:47 AM, Tom DalPozzo wrote:
>         https://www.postgresql.org/docs/9.5/static/wal-internals.html
>         <https://www.postgresql.org/docs/9.5/static/wal-internals.html>
>
>
>     "After a checkpoint has been made and the log flushed, the
>     checkpoint's position is saved in the file pg_control. Therefore, at
>     the start of recovery, the server first reads pg_control and then
>     the checkpoint record; then it performs the REDO operation by
>     scanning forward from the log position indicated in the checkpoint
>     record. Because the entire content of data pages is saved in the log
>     on the first page modification after a checkpoint (assuming
>     full_page_writes is not disabled), all pages changed since the
>     checkpoint will be restored to a consistent state."
>
>
> Hi, yes I know that, it's what I meant in my point 3). As it says first
>  "the checkpoint's position (NOT the record)is saved in the file
> pg_control" then I had some doubt.

Reread your original post and realized you where also asking about
transaction consistency and WALs. The thumbnail version is that Postgres
writes transactions to the WALs before they are written to the data
files on disk. A checkpoint represents a point in the sequence when is
is known that the changes recorded in the WAL have been also recorded in
the disk data files. So Postgres then knows that in a recovery scenario
it needs to only redo/replay the WAL changes that are past the last
checkpoint. So the transactions are there it is just a matter of if they
need to be replayed or not. This is subject to caveats:

https://www.postgresql.org/docs/9.5/static/wal-reliability.html

> Regards
> Pupillo
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] checkpoint clarifications needed
Next
From: Adrian Klaver
Date:
Subject: Re: R: R: [GENERAL] Postgres 9.6.1 big slowdown by upgrading 8.4.22