postgresql/src/backend/access
Tom Lane 6f2aead1ff In XLogReadBufferExtended, don't assume P_NEW yields consecutive pages.
In a database that's not yet reached consistency, it's possible that some
segments of a relation are not full-size but are not the last ones either.
Because of the way smgrnblocks() works, asking for a new page with P_NEW
will fill in the last not-full-size segment --- and if that makes it full
size, the apparent EOF of the relation will increase by more than one page,
so that the next P_NEW request will yield a page past the next consecutive
one.  This breaks the relation-extension logic in XLogReadBufferExtended,
possibly allowing a page update to be applied to some page far past where
it was intended to go.  This appears to be the explanation for reports of
table bloat on replication slaves compared to their masters, and probably
explains some corrupted-slave reports as well.

Fix the loop to check the page number it actually got, rather than merely
Assert()'ing that dead reckoning got it to the desired place.  AFAICT,
there are no other places that make assumptions about exactly which page
they'll get from P_NEW.

Problem identified by Greg Stark, though this is not the same as his
proposed patch.

It's been like this for a long time, so back-patch to all supported
branches.
2014-02-12 14:52:16 -05:00
..
common Revert C comment change in slot_attisnull() 2014-01-28 12:28:14 -05:00
gin Initialize the entryRes array between each call to triConsistent. 2014-02-07 18:53:31 +02:00
gist Update copyright for 2014 2014-01-07 16:05:30 -05:00
hash Allow use of "z" flag in our printf calls, and use it where appropriate. 2014-01-23 17:18:33 -05:00
heap Allow use of "z" flag in our printf calls, and use it where appropriate. 2014-01-23 17:18:33 -05:00
index Update copyright for 2014 2014-01-07 16:05:30 -05:00
nbtree Remove unnecessary relcache flushes after changing btree metapages. 2014-02-05 13:43:46 -05:00
rmgrdesc Compress GIN posting lists, for smaller index size. 2014-01-22 19:20:58 +02:00
spgist Allow use of "z" flag in our printf calls, and use it where appropriate. 2014-01-23 17:18:33 -05:00
transam In XLogReadBufferExtended, don't assume P_NEW yields consecutive pages. 2014-02-12 14:52:16 -05:00
Makefile Split out rmgr rm_desc functions into their own files 2012-11-28 13:01:15 -03:00