postgresql/src/backend/storage
Heikki Linnakangas 1c02ee314b Fix WAL-logging of FSM and VM truncation.
When a relation is truncated, it is important that the FSM is truncated as
well. Otherwise, after recovery, the FSM can return a page that has been
truncated away, leading to errors like:

ERROR:  could not read block 28991 in file "base/16390/572026": read only 0
of 8192 bytes

We were using MarkBufferDirtyHint() to dirty the buffer holding the last
remaining page of the FSM, but during recovery, that might in fact not
dirty the page, and the FSM update might be lost.

To fix, use the stronger MarkBufferDirty() function. MarkBufferDirty()
requires us to do WAL-logging ourselves, to protect from a torn page, if
checksumming is enabled.

Also fix an oversight in visibilitymap_truncate: it also needs to WAL-log
when checksumming is enabled.

Analysis by Pavan Deolasee.

Discussion: <CABOikdNr5vKucqyZH9s1Mh0XebLs_jRhKv6eJfNnD2wxTn=_9A@mail.gmail.com>

Backpatch to 9.3, where we got data checksums.
2016-10-19 15:00:34 +03:00
..
buffer Finish up XLOG_HINT renaming 2016-06-17 18:05:55 -04:00
file Introduce durable_rename() and durable_link_or_rename(). 2016-03-09 18:53:54 -08:00
freespace Fix WAL-logging of FSM and VM truncation. 2016-10-19 15:00:34 +03:00
ipc Fix --disable-spinlocks in 9.2 and 9.3 branches. 2016-04-18 13:19:52 -04:00
large_object Add defenses against running with a wrong selection of LOBLKSIZE. 2014-06-05 11:31:09 -04:00
lmgr Fix --disable-spinlocks in 9.2 and 9.3 branches. 2016-04-18 13:19:52 -04:00
page Fix off-by-one error in Assertion. 2015-05-19 19:25:54 +03:00
smgr Fix mdtruncate() to close fd.c handle of deleted segments. 2016-09-08 16:52:13 -07:00
Makefile Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00