Hi,
>Did you ever see the WARNING with a DATABASE command, or just with a
>TABLESPACE command?
We tried this, but there is no WARNING on GRANT xxx ON DATABASE command.
But I did notice a warning while REVOKE xxx ON TABLESPACE.
$ psql -x -p 5432 -d postgres -c "REVOKE CREATE ON TABLESPACE test_tbl_spc FROM nmluser1;"
WARNING: you don't own a lock of type ExclusiveLock
REVOKE
So both GRANT and REVOKE command on TABLESPACE seems to throw an WARNING.
Best Regards,
Aya Iwata
Fujitsu
> -----Original Message-----
> From: Noah Misch <noah@leadboat.com>
> Sent: Thursday, November 21, 2024 10:11 AM
> To: Iwata, Aya/岩田 彩 <iwata.aya@fujitsu.com>
> Cc: pgsql-bugs@lists.postgresql.org
> Subject: Re: 'WARNING: you don't own a lock of type ExclusiveLock' is printed
> during the GRANT command on PostgreSQL16.5
>
> 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.