Re: Fix races conditions in DropRole() and GrantRole() - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Fix races conditions in DropRole() and GrantRole()
Date
Msg-id alcAi0scidMqjO4y@bdtpg
Whole thread
In response to Re: Fix races conditions in DropRole() and GrantRole()  (surya poondla <suryapoondla4@gmail.com>)
Responses Re: Fix races conditions in DropRole() and GrantRole()
List pgsql-hackers
Hi Surya,

On Fri, Jul 10, 2026 at 02:42:26PM -0700, surya poondla wrote:
> Instead we can report the OID and it avoids the re-lookup entirely, e.g.
> 
>        if (!SearchSysCacheExists1(AUTHOID, ObjectIdGetDatum(roleid)))
>            ereport(ERROR,
>                    (errcode(ERRCODE_UNDEFINED_OBJECT),
>                     errmsg("role with OID %u does not exist", roleid)));

Agreed and done in the attached.

> 2. The new s2_check_orphans permutations all use named roles, which go
> through the RoleNameGetOid() (CSTRING) path. None exercise the
> CURRENT_USER/SESSION_USER else-branch that the recheck was added for.
> A permutation like "GRANT g TO CURRENT_USER" with a concurrent drop of the
> session's login
> role would cover that else branch and this would also exercise the path in
> point #1

Test added.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-hackers by date:

Previous
From: solai v
Date:
Subject: Re: [PATCH] Cover get_json_table_plan() with tests
Next
From: wenhui qiu
Date:
Subject: Re: Report oldest xmin source when autovacuum cannot remove tuples