pgsql: Fix bogus lock release in RemovePolicyById and RemoveRoleFromObj

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix bogus lock release in RemovePolicyById and RemoveRoleFromObj
Date: 2016-01-04 01:53:49
Message-ID: E1aFuLF-0005v0-Jw@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix bogus lock release in RemovePolicyById and RemoveRoleFromObjectPolicy.

Can't release the AccessExclusiveLock on the target table until commit.
Otherwise there is a race condition whereby other backends might service
our cache invalidation signals before they can actually see the updated
catalog rows.

Just to add insult to injury, RemovePolicyById was closing the rel (with
incorrect lock drop) and then passing the now-dangling rel pointer to
CacheInvalidateRelcache. Probably the reason this doesn't fall over on
CLOBBER_CACHE buildfarm members is that some outer level of the DROP logic
is still holding the rel open ... but it'd have bit us on the arse
eventually, no doubt.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f47b602df80d7647ca2e71c86f7228b1bf5bf9f3

Modified Files
--------------
src/backend/commands/policy.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-01-04 06:04:04 pgsql: Fix regrole and regnamespace types to honor quoting like other r
Previous Message Tom Lane 2016-01-04 01:04:19 pgsql: Do some copy-editing on the docs for row-level security.