]> granicus.if.org Git - postgresql/commit
Fix off-by-one possibly leading to skipped XLOG_RUNNING_XACTS records.
authorAndres Freund <andres@anarazel.de>
Sat, 6 May 2017 23:47:40 +0000 (16:47 -0700)
committerAndres Freund <andres@anarazel.de>
Sat, 6 May 2017 23:55:07 +0000 (16:55 -0700)
commite6c44eef55cda493c759e926cecceb92186159b8
tree96f6da115893bd9bbd4d7c4e1def1337c4cecdd3
parent334b82cd56a65e09154d9f930d35a761a9c5cfab
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
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c