pgsql: Fix cleanup lock acquisition in SPLIT_ALLOCATE_PAGE replay.

Lists: pgsql-committers
From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix cleanup lock acquisition in SPLIT_ALLOCATE_PAGE replay.
Date: 2022-11-14 05:23:57
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-committers

Fix cleanup lock acquisition in SPLIT_ALLOCATE_PAGE replay.

During XLOG_HASH_SPLIT_ALLOCATE_PAGE replay, we were checking for a
cleanup lock on the new bucket page after acquiring an exclusive lock on
it and raising a PANIC error on failure. However, it is quite possible
that checkpointer can acquire the pin on the same page before acquiring a
lock on it, and then the replay will lead to an error. So instead, directly
acquire the cleanup lock on the new bucket page during
XLOG_HASH_SPLIT_ALLOCATE_PAGE replay operation.

Reported-by: Andres Freund
Author: Robert Haas
Reviewed-By: Amit Kapila, Andres Freund, Vignesh C
Backpatch-through: 11
Discussion: https://postgr.es/m/[email protected]

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/20c22333630111718bc97ce9a19b392f23e3c525

Modified Files
--------------
src/backend/access/hash/hash_xlog.c | 5 ++---
src/backend/access/hash/hashpage.c | 10 +++++++---
2 files changed, 9 insertions(+), 6 deletions(-)