pgsql: Fix hash index redo reading a torn primary bucket page.

Поиск
Список
Период
Сортировка
Искать

pgsql: Fix hash index redo reading a torn primary bucket page.

От:
Amit Kapila <akapila@postgresql.org>
Дата:
Fix hash index redo reading a torn primary bucket page.

Replay of XLOG_HASH_DELETE, XLOG_HASH_MOVE_PAGE_CONTENTS and
XLOG_HASH_SQUEEZE_PAGE reads the primary bucket page only to take a
cleanup lock on it, so that no hot standby scan runs in the bucket while
tuples are removed or moved. VACUUM holds only a pin on that page, so
these records do not modify it and carry no full-page image of it.

If the on-disk page is torn and the full-page image that repairs it comes
later in the WAL, this read fails with "invalid page". That can happen in
crash recovery, and on a standby started from a base backup whose copy of
the page is torn.

The lock is needed only to serialize against hot standby scans, which can
run only once recovery has reached consistency. Skip the read and lock
while HotStandbyActiveInReplay() is false. This also avoids reading the
page before its repairing image has been replayed, since that image always
precedes the consistency point.

Reported-by: shihao zhong 
Author: Greg Burd 
Co-authored-by: Vignesh C 
Suggested-by: Amit Kapila 
Reviewed-by: Joao Rito 
Reviewed-by: Amit Kapila 
Discussion: https://postgr.es/m/CAGRkXqT_AiwcsWZg5hnR1L2oWO8UpQpkL0iAjoZR+bey=GOWaQ@mail.gmail.com
Discussion: https://postgr.es/m/CAA4eK1LwZk0MaK0LncZz6hsqcHnamfJB47nA8xuwRp4CyLFKzw@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/573ed87c4cfeeed8be9aff03ead242c9122b0fc8

Modified Files
--------------
src/backend/access/hash/hash_xlog.c       | 52 +++++++++++++++++++++++++------
src/backend/access/transam/xlogrecovery.c |  3 +-
src/include/access/xlogrecovery.h         |  1 +
3 files changed, 45 insertions(+), 11 deletions(-)

FAQ