postgresql/src/backend/access
Michael Paquier c186ba135e Ensure correct minimum consistent point on standbys
Startup process has improved its calculation of incorrect minimum
consistent point in 8d68ee6, which ensures that all WAL available gets
replayed when doing crash recovery, and has introduced an incorrect
calculation of the minimum recovery point for non-startup processes,
which can cause incorrect page references on a standby when for example
the background writer flushed a couple of pages on-disk but was not
updating the control file to let a subsequent crash recovery replay to
where it should have.

The only case where this has been reported to be a problem is when a
standby needs to calculate the latest removed xid when replaying a btree
deletion record, so one would need connections on a standby that happen
just after recovery has thought it reached a consistent point.  Using a
background worker which is started after the consistent point is reached
would be the easiest way to get into problems if it connects to a
database.  Having clients which attempt to connect periodically could
also be a problem, but the odds of seeing this problem are much lower.

The fix used is pretty simple, as the idea is to give access to the
minimum recovery point written in the control file to non-startup
processes so as they use a reference, while the startup process still
initializes its own references of the minimum consistent point so as the
original problem with incorrect page references happening post-promotion
with a crash do not show up.

Reported-by: Alexander Kukushkin
Diagnosed-by: Alexander Kukushkin
Author: Michael Paquier
Reviewed-by: Kyotaro Horiguchi, Alexander Kukushkin
Discussion: https://postgr.es/m/153492341830.1368.3936905691758473953@wrigleys.postgresql.org
Backpatch-through: 9.3
2018-08-31 11:03:40 -07:00
..
brin Fail BRIN control functions during recovery explicitly 2018-06-14 12:51:32 -04:00
common Deduplicate code between slot_getallattrs() and slot_getsomeattrs(). 2018-08-23 16:58:53 -07:00
gin doc: Update uses of the word "procedure" 2018-08-22 14:44:49 +02:00
gist doc: Update uses of the word "procedure" 2018-08-22 14:44:49 +02:00
hash doc: Update uses of the word "procedure" 2018-08-22 14:44:49 +02:00
heap Update FSM on WAL replay of page all-visible/frozen 2018-08-15 18:09:29 -03:00
index Revise BuildIndexValueDescription to simplify it 2018-07-16 20:20:15 -04:00
nbtree Reduce path length for locking leaf B-tree pages during insertion 2018-07-28 00:31:40 +03:00
rmgrdesc printf("%lf") is not portable, so omit the "l". 2018-05-20 11:40:54 -04:00
spgist doc: Update uses of the word "procedure" 2018-08-22 14:44:49 +02:00
tablesample Rethink how to get float.h in old Windows API for isnan/isinf 2018-07-11 09:11:48 -04:00
transam Ensure correct minimum consistent point on standbys 2018-08-31 11:03:40 -07:00
Makefile TABLESAMPLE, SQL Standard and extensible 2015-05-15 14:37:10 -04:00