postgresql/src/backend
Michael Paquier 4a9a5bb3fd 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:04:33 -07:00
..
access Ensure correct minimum consistent point on standbys 2018-08-31 11:04:33 -07:00
bootstrap Add macros to make AllocSetContextCreate() calls simpler and safer. 2016-08-27 17:50:38 -04:00
catalog Add table relcache invalidation to index builds. 2018-08-03 14:44:44 -07:00
commands Fix set of NLS translation issues 2018-08-21 15:18:00 +09:00
executor Set scan direction appropriately for SubPlans (bug #15336) 2018-08-17 16:19:10 +01:00
foreign Remove GetUserMappingId() and GetUserMappingById(). 2016-07-22 11:32:23 -04:00
lib Revert "Permit dump/reload of not-too-large >1GB tuples" 2016-12-06 12:46:03 -03:00
libpq Fix set of NLS translation issues 2018-08-21 15:18:00 +09:00
main Install Windows crash dump handler before all else. 2017-11-12 14:31:04 -08:00
nodes Fix parallel query so it doesn't spoil row estimates above Gather. 2017-03-31 21:10:30 -04:00
optimizer Fix print of Path nodes when using OPTIMIZER_DEBUG 2018-07-19 09:55:25 +09:00
parser Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:35:49 +01:00
po Translation updates 2018-08-06 19:44:29 +02:00
port Fix and improve pg_atomic_flag fallback implementation. 2018-04-06 20:02:02 -07:00
postmaster Stop bgworkers during fast shutdown with postmaster in startup phase 2018-08-29 17:11:27 -07:00
regex Fix regexport.c to behave sanely with lookaround constraints. 2017-04-13 17:18:35 -04:00
replication Close the file descriptor in ApplyLogicalMappingFile 2018-08-16 16:52:44 +02:00
rewrite Fix set of NLS translation issues 2018-08-21 15:18:00 +09:00
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Fix inadequate buffer locking in FSM and VM page re-initialization. 2018-07-13 11:53:14 -04:00
tcop Don't run atexit callbacks in quickdie signal handlers. 2018-08-08 19:09:33 +03:00
tsearch Fix bogus affix-merging code. 2018-04-12 18:39:51 -04:00
utils Avoid quadratic slowdown in regexp match/split functions. 2018-08-28 11:51:57 +01:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile Fix make rules that generate multiple output files. 2018-03-23 13:45:38 -04:00
nls.mk Translation updates 2018-08-06 19:44:29 +02:00