BUG #18719: Bug Report for Patch (For inplace update durability, make heap_update() callers wait)

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: xliudut(at)gmail(dot)com
Subject: BUG #18719: Bug Report for Patch (For inplace update durability, make heap_update() callers wait)
Date: 2024-11-21 10:35:47
Message-ID: 18719-da275243dd2e10e0@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18719
Logged by: Daniels Evan
Email address: xliudut(at)gmail(dot)com
PostgreSQL version: 16.5
Operating system: linux CentOS 7
Description:

In the recently released REL_16_6 version, this patch (“For inplace update
durability, make heap_update() callers wait”) has an issue that causes
abnormal WARNING related to tablespace access.

The reproduction steps are as follows: after compiling the code with this
patch, execute the following script:

CREATE ROLE grantee_test_another LOGIN;

-- Assuming this path is valid
\! mkdir -p /tmp/tablespace
CREATE TABLESPACE tablespace_test_a OWNER granter_test LOCATION
'/tmp/tablespace';

-- Disconnect and then reconnect, then execute this SQL
GRANT ALL ON TABLESPACE tablespace_test_a to grantee_test_another;

-- The following error is expected
postgres=# GRANT ALL ON TABLESPACE tablespace_test_a to
grantee_test_another;
WARNING: you don't own a lock of type ExclusiveLock
WARNING: tuple lock held at commit
GRANT
I conducted an initial investigation and found that the cause of this issue
is the newly introduced function in the patch (SearchSysCacheLocked1), which
has a problem:

Oid dboid =
SysCache[cacheId]->cc_relisshared ? InvalidOid : MyDatabaseId;

When dealing with a TABLESPACE object, it incorrectly determines that
MyDatabaseId exists and attaches it. As a result, during the LockAcquire
phase, the LockTag is set to (5,1213,0,16), and during
UnlockTuple->LockRelease, the LockTag becomes (0,1213,0,16).

Below is a snippet of the log I printed during the verification of the
issue:

$tmp_polardb_pg_16_base/bin/psql
psql (16.6)
Type "help" for help.

postgres=# GRANT ALL ON TABLESPACE tablespace_test_a to
grantee_test_another;
WARNING: Accquire: 0, 1213, 1
WARNING: Release: 0, 1213, 1
WARNING: Accquire: 0, 1213, 3
WARNING: Accquire: 0, 1213, 1
WARNING: Release: 0, 1213, 1
WARNING: Accquire: 0, 1213, 1
WARNING: Release: 0, 1213, 1
WARNING: Accquire: 5, 1213, 7
WARNING: Release: 0, 1213, 7
WARNING: you don't own a lock of type ExclusiveLock
WARNING: Release: 0, 1213, 3
WARNING: tuple lock held at commit
GRANT

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Kukushkin 2024-11-21 10:42:13 Re: pg_rewind WAL segments deletion pitfall
Previous Message PG Bug reporting form 2024-11-21 08:26:34 BUG #18718: Incorrect Twitter/X Logo Displayed on PostgreSQL Documentation Page