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

From Alvaro Herrera
Subject Re: [GENERAL] checkpoint clarifications needed
Date
Msg-id 20170109220123.2j5u7ey4cm42snho@alvherre.pgsql
Whole thread Raw
In response to [GENERAL] checkpoint clarifications needed  (Tom DalPozzo <t.dalpozzo@gmail.com>)
List pgsql-general
Tom DalPozzo wrote:

> 2) I see that a checkpoint position can be right in the middle of a group
> of records related to a transaction (in the example, transaction id 10684).
> So a checkpoint position is NOT a consistency state point, right?

> 4) If I'm right at 2) then, between the checkpoint position (1/F00A7448 )
> and the checkpoint record position (1/FCBD7510) there must be a point where
> the DB is in a consistency state. If not, in case of crash just after
> writing the checkpoint record to the WAL and its position to pg_control,
> the system would replay from the checkpoint position (known by  last
> checkpoint record) without finding a consistency state. Right?
>
> 5) How can we define, in terms of log records, a consistency state position?

Whether any individual tuple in the data files is visible or not depends
not only on the data itself, but also on the commit status of the
transactions that created it (and deleted it, if any).  Replaying WAL
also updates the commit status of transactions, so if you're in the
middle of replaying WAL, you may be adding tuples to the data files, but
those tuples will not become visible until their commit records are also
updated.

You can stop replaying WAL at any point, and data will always be in a
consistent state.  Some data tuples might be "from the future" and those
will not be visible, which is what makes it all consistent.

--
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-general by date:

Previous
From: Job
Date:
Subject: [GENERAL] Matching indexe for timestamp
Next
From: Tom DalPozzo
Date:
Subject: Re: [GENERAL] checkpoint clarifications needed