pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix hash index redo reading a torn primary bucket page.
6+ messages / 1 participants
[nested] [flat]

* pgsql: Fix hash index redo reading a torn primary bucket page.
@ 2026-11-18 03:53 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2026-11-18 03:53 UTC (permalink / raw)
  To: pgsql-committers@lists.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 <zhong950419@gmail.com>
Author: Greg Burd <greg@burd.me>
Co-authored-by: Vignesh C <vignesh21@gmail.com>
Suggested-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Joao Rito <joaovictor.rito@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8becd1123c98cd9338678c6c2d4ae6b4d56a6fb9

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix hash index redo reading a torn primary bucket page.
@ 2026-11-18 03:53 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2026-11-18 03:53 UTC (permalink / raw)
  To: pgsql-committers@lists.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 <zhong950419@gmail.com>
Author: Greg Burd <greg@burd.me>
Co-authored-by: Vignesh C <vignesh21@gmail.com>
Suggested-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Joao Rito <joaovictor.rito@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
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_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/21c45d45d04efab45cf73c491127bfe4a31743a3

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix hash index redo reading a torn primary bucket page.
@ 2026-11-18 03:53 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2026-11-18 03:53 UTC (permalink / raw)
  To: pgsql-committers@lists.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 <zhong950419@gmail.com>
Author: Greg Burd <greg@burd.me>
Co-authored-by: Vignesh C <vignesh21@gmail.com>
Suggested-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Joao Rito <joaovictor.rito@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
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_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ed2cc619ac74733c7d20b48131714550e4ce1a08

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix hash index redo reading a torn primary bucket page.
@ 2026-11-18 03:53 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2026-11-18 03:53 UTC (permalink / raw)
  To: pgsql-committers@lists.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 <zhong950419@gmail.com>
Author: Greg Burd <greg@burd.me>
Co-authored-by: Vignesh C <vignesh21@gmail.com>
Suggested-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Joao Rito <joaovictor.rito@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
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_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cfdb86434de5eb3f2bda0f8c35bbe9a34e423e0e

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix hash index redo reading a torn primary bucket page.
@ 2026-11-18 03:53 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2026-11-18 03:53 UTC (permalink / raw)
  To: pgsql-committers@lists.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 <zhong950419@gmail.com>
Author: Greg Burd <greg@burd.me>
Co-authored-by: Vignesh C <vignesh21@gmail.com>
Suggested-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Joao Rito <joaovictor.rito@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix hash index redo reading a torn primary bucket page.
@ 2026-11-18 03:53 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2026-11-18 03:53 UTC (permalink / raw)
  To: pgsql-committers@lists.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 <zhong950419@gmail.com>
Author: Greg Burd <greg@burd.me>
Co-authored-by: Vignesh C <vignesh21@gmail.com>
Suggested-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Joao Rito <joaovictor.rito@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
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_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0e278a7ddee4093674d7ee8205423d2dea7ce672

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(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2026-11-18 03:53 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 03:53 pgsql: Fix hash index redo reading a torn primary bucket page. Amit Kapila <akapila@postgresql.org>
2026-11-18 03:53 pgsql: Fix hash index redo reading a torn primary bucket page. Amit Kapila <akapila@postgresql.org>
2026-11-18 03:53 pgsql: Fix hash index redo reading a torn primary bucket page. Amit Kapila <akapila@postgresql.org>
2026-11-18 03:53 pgsql: Fix hash index redo reading a torn primary bucket page. Amit Kapila <akapila@postgresql.org>
2026-11-18 03:53 pgsql: Fix hash index redo reading a torn primary bucket page. Amit Kapila <akapila@postgresql.org>
2026-11-18 03:53 pgsql: Fix hash index redo reading a torn primary bucket page. Amit Kapila <akapila@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox