pgsql: Fix locking when fixing an incomplete split of a GIN internal pa

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix locking when fixing an incomplete split of a GIN internal pa
Date: 2024-01-29 11:52:37
Message-ID: E1rUQBp-003gCK-NB@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix locking when fixing an incomplete split of a GIN internal page

ginFinishSplit() expects the caller to hold an exclusive lock on the
buffer, but when finishing an earlier "leftover" incomplete split of
an internal page, the caller held a shared lock. That caused an
assertion failure in MarkBufferDirty(). Without assertions, it could
lead to corruption if two backends tried to complete the split at the
same time.

On master, add a test case using the new injection point facility.

Report and analysis by Fei Changhong. Backpatch the fix to all
supported versions.

Reviewed-by: Fei Changhong, Michael Paquier
Discussion: https://www.postgresql.org/message-id/tencent_A3CE810F59132D8E230475A5F0F7A08C8307@qq.com

Branch
------
REL_12_STABLE

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

Modified Files
--------------
src/backend/access/gin/ginbtree.c | 68 ++++++++++++++++++++++++++++-----------
1 file changed, 50 insertions(+), 18 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2024-01-29 16:55:27 pgsql: Add EXPLAIN (MEMORY) to report planner memory consumption
Previous Message Alvaro Herrera 2024-01-29 11:41:43 pgsql: libpq: Move cancellation related functions to fe-cancel.c