BUG #17182: Race condition on concurrent DROP and CREATE of dependent object

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #17182: Race condition on concurrent DROP and CREATE of dependent object
Date: 2021-09-04 06:00:00
Message-ID: 17182-a6baa001dd1784be@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17182
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message hubert depesz lubaczewski 2021-09-05 11:28:33 Logs vanish after partial log destination change
Previous Message PG Bug reporting form 2021-09-03 20:36:44 BUG #17181: pg_cancel_backend and pg_terminate_backend fail to work