Re: BUG #18912: TRAP: failed Assert("tag.spcOid != GLOBALTABLESPACE_OID"), File: "bufmgr.c", Line: 4165, PID: 2115

From: Noah Misch <noah(at)leadboat(dot)com>
To: adamguo(at)amazon(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18912: TRAP: failed Assert("tag.spcOid != GLOBALTABLESPACE_OID"), File: "bufmgr.c", Line: 4165, PID: 2115
Date: 2025-05-06 00:31:01
Message-ID: 20250506003101.51.nmisch@google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, May 05, 2025 at 10:01:15PM +0000, PG Bug reporting form wrote:
> ```
> CREATE USER myuser;
> REINDEX SCHEMA pg_catalog;
> SET SESSION AUTHORIZATION myuser;
> GRANT ALTER SYSTEM ON PARAMETER log_filename TO myuser;
> GRANT ALTER SYSTEM ON PARAMETER log_filename TO myuser WITH GRANT OPTION;
> ```
> From what I can tell, all of these statements are necessary to reproduce the
> error. On the last one, the backend aborts at buffer/bufmgr.c:4165 [1].
> This
> assert was introduced in f4ece891 [2]. Seems like something is holding onto
> an
> LW_EXCLUSIVE lock on a system catalog?
> According to gdb, the relation in question is not a system catalog but does
> live
> in the pg_global tablespace. I can't find it in pg_class.
> ```
> (gdb) up 3
> #3 0x00000000009e1f48 in AssertNotCatalogBufferLock (lock=0x7f8ab5782c30,
> mode=LW_EXCLUSIVE,
> unused_context=0x0) at bufmgr.c:4165
> 4165 Assert(tag.spcOid != GLOBALTABLESPACE_OID);
> (gdb) p tag.spcOid
> $1 = 1664
> (gdb) p relid
> $2 = 16526
> ```

Thanks for the report. On my system, it's pg_parameter_acl_parname_index:

[local] test=*# select pg_filenode_relation(1664, '16529');
pg_filenode_relation
────────────────────────────────
pg_parameter_acl_parname_index
(1 row)

That's an IsCatalogTextUniqueIndexOid() index, but the REINDEX makes
AssertNotCatalogBufferLock() unable to detect it as one. Hence, I think I'll
be removing the assert you reached:

--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -4160,10 +4160,8 @@ AssertNotCatalogBufferLock(LWLock *lock, LWLockMode mode,
if (IsCatalogTextUniqueIndexOid(relid)) /* see comments at the callee */
return;

Assert(!IsCatalogRelationOid(relid));
- /* Shared rels are always catalogs: detect even after VACUUM FULL. */
- Assert(tag.spcOid != GLOBALTABLESPACE_OID);
}

It's true that shared rels are always catalogs. However, without a way to
judge IsCatalogTextUniqueIndexOid(), we can't assert-fail.

> [1]
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/storage/buffer/bufmgr.c;hb=HEAD#l4165
> [2]
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=f4ece891fc2f

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Masahiko Sawada 2025-05-06 04:52:51 Re: BUG #18912: TRAP: failed Assert("tag.spcOid != GLOBALTABLESPACE_OID"), File: "bufmgr.c", Line: 4165, PID: 2115
Previous Message PG Bug reporting form 2025-05-05 22:01:15 BUG #18912: TRAP: failed Assert("tag.spcOid != GLOBALTABLESPACE_OID"), File: "bufmgr.c", Line: 4165, PID: 2115