On Mon, May 5, 2025 at 5:31 PM Noah Misch <noah@leadboat.com> wrote:
>
> 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);
> }
+1. Seems reasonable approach.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com