pgsql: Fix bogus lock release in RemovePolicyById and RemoveRoleFromObj - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix bogus lock release in RemovePolicyById and RemoveRoleFromObj
Date
Msg-id E1aFuLF-0005v1-K2@gemulon.postgresql.org
Whole thread Raw
List 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
------
REL9_5_STABLE

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

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


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Do some copy-editing on the docs for row-level security.
Next
From: Tom Lane
Date:
Subject: pgsql: Fix bogus lock release in RemovePolicyById and RemoveRoleFromObj