'WARNING: you don't own a lock of type ExclusiveLock' is printed during the GRANT command on PostgreSQL16.5
Hi developers,
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.
[Details]
Version:
16.5
OS:
Linux
Build options:
--prefix=/xxx/xxx/xxx' '--with-ssl=openssl' '--without-icu
Build and install command:
make all
make install
Reproduction procedure:
1. Set binaries bin and lib path
2. Initiate the server using initdb command
3. create folder for tablespace
4. start the server usaing pg_ctl command
5. execute the following commands:
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
[Investigated]
- This WARNING did not occur when tested with FEP16.4 using the same "Reproduction procedure:"
- This WARNING did not occur when running CREATE ROLE through GRANT in a single session connected to psql.
- Also, it did not happen when running 'psql -f' with an .sql file
- We have run similar tests in the November releases of v12 through v17, but this is not reported by the tester in those releases.
-- Therefore, we have not tried this "Reproduction procedure:" on versions other than 16.5 and 16.4.
- This WARNING message appears in several places, and after modifying the source code to know which elog it is,
seemed to come from ReleaseSysCache() in ExecGrant_common()
Regards,
Aya Iwata
Fujitsu
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.[Details]
Version:
16.5
1. Set binaries bin and lib path
2. Initiate the server using initdb command
3. create folder for tablespace
4. start the server usaing pg_ctl command
5. execute the following commands: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[Investigated]
- This WARNING did not occur when tested with FEP16.4 using the same "Reproduction procedure:"
- This WARNING did not occur when running CREATE ROLE through GRANT in a single session connected to psql.
- Also, it did not happen when running 'psql -f' with an .sql file
- We have run similar tests in the November releases of v12 through v17, but this is not reported by the tester in those releases.
-- Therefore, we have not tried this "Reproduction procedure:" on versions other than 16.5 and 16.4.
- This WARNING message appears in several places, and after modifying the source code to know which elog it is,
seemed to come from ReleaseSysCache() in ExecGrant_common()
Thanks for the report. This seems reasonably likely to come from a defect in
commit 51ff46d. I will look into it.
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.
Attachments:
inplace250-catcache-init-SearchSysCacheLocked1-v1.patchtext/plain; charset=us-asciiDownload+21-5
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
Show quoted text
-----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.5On 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 postgresTO nmluser1;"
GRANT
$ psql -d postgres -c "GRANT ALL PRIVILEGES ON DATABASEenc_testdb TO nmluser1;"
GRANT
$ psql -d postgres -c "GRANT CREATE ON TABLESPACE test_tblspace TOnmluser1;"
WARNING: you don't own a lock of type ExclusiveLock
GRANTDid 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.
On Mon, Nov 25, 2024 at 05:54:50AM +0000, Aya Iwata (Fujitsu) wrote:
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
REVOKESo both GRANT and REVOKE command on TABLESPACE seems to throw an WARNING.
That makes sense. I've pushed postgr.es/c/4ba84de for this.