DROP OWNED CASCADE vs Temp tables

Mithun Cy <[email protected]> Tue, 7 Jan 2020 12:52:00 +0530
Newsgroups gmane.comp.db.postgresql.devel.general,gmane.comp.db.postgresql.bugs
Message-ID <CADq3xVZTbzK4ZLKq+dn_vB4QafXXbmMgDP3trY-GuLnib2Ai1w@mail.gmail.com>
--000000000000e2bee4059b87a329
Content-Type: text/plain; charset="UTF-8"

I have a test where a user creates a temp table and then disconnect,
concurrently we try to do DROP OWNED BY CASCADE on the same user. Seems
this causes race condition between temptable deletion during disconnection
(@RemoveTempRelations(myTempNamespace)) and DROP OWNED BY CASCADE operation
which will try to remove same temp table when they find them as part of
pg_shdepend. Which will result in internal error cache lookup failed as
below.

DROP OWNED BY test_role CASCADE;
2020-01-07 12:35:06.524 IST [26064] ERROR:  cache lookup failed for
relation 41019
2020-01-07 12:35:06.524 IST [26064] STATEMENT:  DROP OWNED BY test_role
CASCADE;
reproduce.sql:8: ERROR:  cache lookup failed for relation 41019

TEST
=====================
create database test_db;
create user test_superuser superuser;
\c test_db test_superuser
CREATE ROLE test_role nosuperuser login password 'test_pwd' ;
\c test_db test_role
CREATE TEMPORARY TABLE tmp_table(col1 int);
\c test_db test_superuser
DROP OWNED BY test_role CASCADE;


-- 
Thanks and Regards
Mithun Chicklore Yogendra
EnterpriseDB: http://www.enterprisedb.com

--000000000000e2bee4059b87a329
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I have a test where a user creates a temp table and t=
hen disconnect, concurrently we try to do DROP OWNED BY CASCADE on the same=
 user. Seems this causes race condition between temptable deletion during d=
isconnection (@RemoveTempRelations(myTempNamespace)) and DROP OWNED BY CASC=
ADE operation which will try to remove same temp table when they find them =
as part of pg_shdepend. Which will result in internal error cache lookup fa=
iled as below.<br></div><div><br></div><div>DROP OWNED BY test_role CASCADE=
;<br>2020-01-07 12:35:06.524 IST [26064] ERROR: =C2=A0cache lookup failed f=
or relation 41019<br>2020-01-07 12:35:06.524 IST [26064] STATEMENT: =C2=A0D=
ROP OWNED BY test_role CASCADE;<br>reproduce.sql:8: ERROR: =C2=A0cache look=
up failed for relation 41019<br></div><div><br></div><div>TEST</div><div>=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br></div><d=
iv>create database test_db;<br>create user test_superuser superuser;<br>\c =
test_db test_superuser<br>CREATE ROLE test_role nosuperuser login password =
&#39;test_pwd&#39; ;<br>\c test_db test_role<br>CREATE TEMPORARY TABLE tmp_=
table(col1 int);<br>\c test_db test_superuser<br>DROP OWNED BY test_role CA=
SCADE;<br></div><div><br></div><div><br></div>-- <br><div dir=3D"ltr" class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature">Thanks and Regards<=
br>Mithun Chicklore Yogendra<br>EnterpriseDB: <a href=3D"http://www.enterpr=
isedb.com" target=3D"_blank">http://www.enterprisedb.com</a></div></div>

--000000000000e2bee4059b87a329--