BUG #17182: Race condition on concurrent DROP and CREATE of dependent object - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #17182: Race condition on concurrent DROP and CREATE of dependent object
Date
Msg-id 17182-a6baa001dd1784be@postgresql.org
Whole thread Raw
Responses Re: BUG #17182: Race condition on concurrent DROP and CREATE of dependent object
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17182
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 14beta3
Operating system:   Ubuntu 20.04
Description:

As result of the following script:
for i in `seq 100`; do
( { for n in `seq 20`; do echo "DROP DOMAIN i;"; done } | psql ) >psql1.log
2>&1 &
( echo "
CREATE DOMAIN i AS int;
CREATE FUNCTION f1() RETURNS i LANGUAGE SQL RETURN 1;
CREATE FUNCTION f2() RETURNS i LANGUAGE SQL RETURN 2;
CREATE FUNCTION f3() RETURNS i LANGUAGE SQL RETURN 3;
CREATE FUNCTION f4() RETURNS i LANGUAGE SQL RETURN 4;
CREATE FUNCTION f5() RETURNS i LANGUAGE SQL RETURN 5;
" | psql ) >psql2.log 2>&1 &
wait
psql -c "DROP DOMAIN i CASCADE" >psql3.log 2>&1
done

I get several broken functions with the invalid return type:
SELECT f1()
ERROR:  cache lookup failed for type 16519
CONTEXT:  SQL function "f1" during inlining

\df
ERROR:  cache lookup failed for type 16519
(\df is effectively unusable when such functions exist)

SELECT pp.oid, proname, pronamespace, proowner, prolang, prorettype FROM
pg_proc pp INNER JOIN pg_namespace pn ON (pp.pronamespace = pn.oid) WHERE
pn.nspname='public'
  oid  | proname | pronamespace | proowner | prolang | prorettype 
-------+---------+--------------+----------+---------+------------
 16520 | f1      |         2200 |       10 |      14 |      16519
 16521 | f2      |         2200 |       10 |      14 |      16519
 16564 | f3      |         2200 |       10 |      14 |      16563
 16565 | f4      |         2200 |       10 |      14 |      16563
 16616 | f5      |         2200 |       10 |      14 |      16615
(5 rows)

The similar behaviour is reproduced with "CREATE SCHEMA s; CREATE FUNCTION
s.funcX ... / DROP SCHEMA s;", but \df *.func* shows such functions with the
empty schema column.


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17181: pg_cancel_backend and pg_terminate_backend fail to work
Next
From: hubert depesz lubaczewski
Date:
Subject: Logs vanish after partial log destination change