Concurrent CREATE USER MAPPING and DROP SERVER

From: Ronan Dunklau <rdunklau(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Concurrent CREATE USER MAPPING and DROP SERVER
Date: 2013-07-04 14:27:35
Message-ID: 2115087.NEu0iG5RhT@ropc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello.

I think I may have found a bug in the CREATE USER MAPPING / DROP SERVER
handling.

It is possible to create a user mapping on a server and drop said server in
two concurrent transactions, and have both succeed.

This results in an orphan row in the pg_user_mapping table.

I would expect one of those transactions to fail.

This is more easily explained with the following example:

CREATE extension postgres_fdw;

CREATE server pg_server FOREIGN DATA WRAPPER postgres_fdw

-- SESSION 1
BEGIN;
CREATE USER MAPPING FOR postgres SERVER pg_server OPTIONS (user 'user');

-- SESSION 2
BEGIN;
DROP SERVER pg_server;

-- SESSION 1
COMMIT;

-- SESSION 2
COMMIT;

select umserver, s.oid from pg_user_mapping left join pg_foreign_server s on
s.oid = pg_user_mapping.umserver;

┌──────────┬─────┐
│ umserver │ oid │
├──────────┼─────┤
│62172 │ ¤ │
└──────────┴─────┘

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-07-04 15:03:30 Re: Concurrent CREATE USER MAPPING and DROP SERVER
Previous Message manish.roy 2013-07-04 12:40:07 BUG #8285: Unable to install the pgAgent