Re: 'WARNING: you don't own a lock of type ExclusiveLock' is printed during the GRANT command on PostgreSQL16.5

From: Noah Misch <noah(at)leadboat(dot)com>
To: "Aya Iwata (Fujitsu)" <iwata(dot)aya(at)fujitsu(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: 'WARNING: you don't own a lock of type ExclusiveLock' is printed during the GRANT command on PostgreSQL16.5
Date: 2024-11-21 01:11:00
Message-ID: 20241121011100.c3.nmisch@google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Nov 19, 2024 at 10:27:42PM -0800, Noah Misch wrote:
> On Wed, Nov 20, 2024 at 05:11:07AM +0000, Aya Iwata (Fujitsu) wrote:
> > During our tests on November release,
> > we discovered a "WARNING: you don't own a lock of type ExclusiveLock" that occurred at a strange time in GRANT command.

> > This is only possible when psql executes each command individually.
> > $ psql -d postgres -c "CREATE USER nmluser1;"
> > CREATE ROLE
> > $ psql -d postgres -c "CREATE TABLESPACE test_tblspace LOCATION '/xxx /xxx/pgsql16.5/tbs';"
> > CREATE TABLESPACE
> > $ psql -d postgres -c "CREATE DATABASE enc_testdb;"
> > CREATE DATABASE
> > $ psql -d postgres -c "GRANT ALL PRIVILEGES ON DATABASE postgres TO nmluser1;"
> > GRANT
> > $ psql -d postgres -c "GRANT ALL PRIVILEGES ON DATABASE enc_testdb TO nmluser1;"
> > GRANT
> > $ psql -d postgres -c "GRANT CREATE ON TABLESPACE test_tblspace TO nmluser1;"
> > WARNING:  you don't own a lock of type ExclusiveLock
> > GRANT

Did you ever see the WARNING with a DATABASE command, or just with a
TABLESPACE command?

> Thanks for the report. This seems reasonably likely to come from a defect in
> commit 51ff46d. I will look into it.

Yes, that commit had us reading cc_relisshared before that field got
initialized. I can reproduce the WARNING in v16+, with GRANT TABLESPACE.
Before a cache's initialization cc_relisshared==false, so
SearchSysCacheLocked1() used the wrong locktag. The attached patch is about
right. At a minimum, I still need to work on the details in its log message.

Attachment Content-Type Size
inplace250-catcache-init-SearchSysCacheLocked1-v1.patch text/plain 3.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Antonin Houska 2024-11-21 05:43:45 Re: pg_rewind WAL segments deletion pitfall
Previous Message Thomas Munro 2024-11-21 00:42:19 Re: Can not open Postgre SQL 17.1 after update