DROP USER MAPPING doesn't acquire lock on its server

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: DROP USER MAPPING doesn't acquire lock on its server
Date: 2026-12-02 07:09:25
Message-ID: CALdSSPj2BSaEWDAO3fz_vFBJ_3nhmo7ZAy4whUHG4Pn-jQKyfQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

A concurrent DROP SERVER can remove a foreign server that CREATE USER
MAPPING wants to use, on master this produces an internal XX000 cache
lookup error. There is a gap between
get_foreign_server_oid/GetForeignServer which allows this race.

Deterministic test + actual output from today's HEAD attached.

Attached fix resolves the server with get_object_address(...,
AccessShareLock, ...), which protects against concurrent deletion -
this is something other places in core do, for example generic Rename
does it.

+CC Jeff Davis because we committed number of fixes/enhancements in
this area which I find related to issue [0]

[0] https://www.postgresql.org/message-id/95a4a0d1f9b1a2e9d2e339b41b532131571150af.camel%40j-davis.com

--
Best regards,
Kirill Reshke

Attachment Content-Type Size
injection-point-test.patch application/octet-stream 3.9 KB
actual-output.out application/octet-stream 678 bytes
fix.diff application/octet-stream 1.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message solai v 2026-12-02 07:26:37 Re: [PATCH] Add planner support function to two-argument regexp_like()
Previous Message Chao Li 2026-12-02 07:00:47 Re: [PATCH] Reuse slot helpers in pg_get_replication_slots and slot copy