pgsql: Fix off-by-one possibly leading to skipped XLOG_RUNNING_XACTS re

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix off-by-one possibly leading to skipped XLOG_RUNNING_XACTS re
Date: 2017-05-07 00:01:23
Message-ID: E1d79db-0001BO-Lr@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix off-by-one possibly leading to skipped XLOG_RUNNING_XACTS records.

Since 6ef2eba3f57f1 ("Skip checkpoints, archiving on idle systems."),
GetLastImportantRecPtr() is used to avoid performing superfluous
checkpoints, xlog switches, running-xact records when the system is
idle. Unfortunately the check concerning running-xact records had a
off-by-one error, leading to such records being potentially skipped
when only a single record has been inserted since the last
running-xact record.

An alternative approach would have been to change
GetLastImportantRecPtr()'s definition to point to the end of records,
but that would make the checkpoint code more complicated.

Author: Andres Freund
Discussion: https://postgr.es/m/20170505012447.wsrympaxnfis6ojt@alap3.anarazel.de
Backpatch: no, code only present in master

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e6c44eef55cda493c759e926cecceb92186159b8

Modified Files
--------------
src/backend/postmaster/bgwriter.c | 7 +++++--
src/backend/postmaster/checkpointer.c | 3 ++-
2 files changed, 7 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2017-05-07 00:01:26 Re: Change GetLastImportantRecPtr's definition? (wasSkip checkpoints, archiving on idle systems.)
Previous Message Tom Lane 2017-05-06 20:28:28 pgsql: Second pass on 9.6.3 release notes.