pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ronan Dunklau <rdunklau@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: Concurrent CREATE USER MAPPING and DROP SERVER
Date: Thu, 04 Jul 2013 16:27:35 +0200
Message-ID: <2115087.NEu0iG5RhT@ropc> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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    	   │  ¤     │
└──────────┴─────┘
-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


view thread (2+ messages)  latest in thread

Message-ID: <2115087.NEu0iG5RhT@ropc>
Permalink:  ../2115087.NEu0iG5RhT@ropc/
Also on:    postgresql.org/message-id/2115087.NEu0iG5RhT@ropc

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: rdunklau@gmail.com
  Subject: Re: Concurrent CREATE USER MAPPING and DROP SERVER
  In-Reply-To: <2115087.NEu0iG5RhT@ropc>
  References: <2115087.NEu0iG5RhT@ropc>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox