Skip to content

Avoid checking permission of Babelfish temp tables on parallel worker#3683

Merged
Deepesh125 merged 1 commit intobabelfish-for-postgresql:BABEL_2_13_STABLEfrom
amazon-aurora:jira-babel-5703-2-13
Apr 15, 2025
Merged

Avoid checking permission of Babelfish temp tables on parallel worker#3683
Deepesh125 merged 1 commit intobabelfish-for-postgresql:BABEL_2_13_STABLEfrom
amazon-aurora:jira-babel-5703-2-13

Conversation

@Deepesh125
Copy link
Copy Markdown
Contributor

Consider following facts,

Babelfish temp tables are implemented using ENR which is not shared between different backends. So if Parallel worker tries to check permissions on Babelfish then it will fail.

Any user should be able to access Babelfish temp tables under given session.

Postgres by default does not allow parallel operations on temp tables. Attempt to do so will result in run time error.

Due to above facts, we should avoid permission check on temp tables within parallel workers while ensuring that leader does required permission check on other tables. This commits achieves this behaviour by implementing following three hooks,

bbf_ParallelQueryMain_hook -- implements ParallelQueryMain_hook. It constructs Bitmapset (list of temp table oids) by looping through es_range_table checking if given relation is temp table, checks permission if it is and add it to the set. It will then pass this set of temp table defined under current with Parallel workers.

bbf_ExecInitParallelPlan -- implements ExecInitParallelPlan_hook. Parallel workers will gather additional details (oid set of temp table) passed by Leader node. This set will later be used to avoid checking permissions on temp tables.

bbf_ ExecCheckRTEPerms_hook -- implements ExecCheckOneRelPerms_hook. It will avoid permission check relation if relid is part of the set of oids constructed using bbf_ExecInitParallelPlan.

Task: BABEL-5703
Signed-off-by: Dipesh Dhameliya dddhamel@amazon.com
(cherry picked from commit d741f37)

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…babelfish-for-postgresql#3674)

Consider following facts,

Babelfish temp tables are implemented using ENR which is not shared between different backends. So if Parallel
worker tries to check permissions on Babelfish then it will fail.

Any user should be able to access Babelfish temp tables under given session.

Postgres by default does not allow parallel operations on temp tables. Attempt to do so will result in run time error.

Due to above facts, we should avoid permission check on temp tables within parallel workers while ensuring that
leader does required permission check on other tables. This commits achieves this behaviour by implementing
following three hooks,

bbf_ParallelQueryMain_hook -- implements ParallelQueryMain_hook. It constructs Bitmapset (list of temp table oids)
by looping through es_range_table checking if given relation is temp table, checks permission if it is and add it to the
set. It will then pass this set of temp table defined under current with Parallel workers.

bbf_ExecInitParallelPlan -- implements ExecInitParallelPlan_hook. Parallel workers will gather additional details (oid set
of temp table) passed by Leader node. This set will later be used to avoid checking permissions on temp tables.

bbf_ ExecCheckRTEPerms_hook -- implements ExecCheckOneRelPerms_hook. It will avoid permission check relation
if relid is part of the set of oids constructed using bbf_ExecInitParallelPlan.

Task: BABEL-5703
Signed-off-by: Dipesh Dhameliya <dddhamel@amazon.com>
(cherry picked from commit 3ddff85)
(cherry picked from commit d741f37)
Copy link
Copy Markdown
Contributor

@jsudrik jsudrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

@Deepesh125 Deepesh125 merged commit 1831e91 into babelfish-for-postgresql:BABEL_2_13_STABLE Apr 15, 2025
30 checks passed
@Deepesh125 Deepesh125 deleted the jira-babel-5703-2-13 branch April 15, 2025 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants