feat: optimize catalog permission sync#33000
Conversation
|
Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment
|
There was a problem hiding this comment.
I've completed my review and didn't find any issues.
Files scanned
| File Path | Reviewed |
|---|---|
| superset/db_engine_specs/doris.py | ✅ |
| superset/commands/database/sync_permissions.py | ✅ |
| superset/db_engine_specs/snowflake.py | ✅ |
| superset/db_engine_specs/postgres.py | ✅ |
| superset/db_engine_specs/databricks.py | ✅ |
| superset/db_engine_specs/bigquery.py | ✅ |
| superset/db_engine_specs/presto.py | ✅ |
| superset/db_engine_specs/base.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Need a new review? Comment
/korbit-reviewon this PR and I'll review your latest changes.Korbit Guide: Usage and Customization
Interacting with Korbit
- You can manually ask Korbit to review your PR using the
/korbit-reviewcommand in a comment at the root of your PR.- You can ask Korbit to generate a new PR description using the
/korbit-generate-pr-descriptioncommand in any comment on your PR.- Too many Korbit comments? I can resolve all my comment threads if you use the
/korbit-resolvecommand in any comment on your PR.- On any given comment that Korbit raises on your pull request, you can have a discussion with Korbit by replying to the comment.
- Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.
Customizing Korbit
- Check out our docs on how you can make Korbit work best for you and your team.
- Customize Korbit for your organization through the Korbit Console.
Current Korbit Configuration
General Settings
Setting Value Review Schedule Automatic excluding drafts Max Issue Count 10 Automatic PR Descriptions ❌ Issue Categories
Category Enabled Documentation ✅ Logging ✅ Error Handling ✅ Readability ✅ Design ✅ Performance ✅ Security ✅ Functionality ✅ Feedback and Support
Note
Korbit Pro is free for open source projects 🎉
Looking to add Korbit to your team? Get started with a free 2 week trial here
| force=True, | ||
| ssh_tunnel=self.db_connection_ssh_tunnel, | ||
| ) | ||
| # Adding permissions to all catalogs (and all their schemas) can take a long |
There was a problem hiding this comment.
There's a similar check here:
superset/superset/commands/database/sync_permissions.py
Lines 143 to 147 in db959a6
Can these two conditions be consolidated?
There was a problem hiding this comment.
I believe that block is actually calling this method, so I think we're good? Would defer to @betodealmeida to confirm
There was a problem hiding this comment.
Yeah, those are different.
Basically with my changes _get_catalog_names returns all relevant catalogs in a given database. This could be all catalogs, or just the default.
When a database doesn't support catalogs, then we need to use None as the catalog, hence the [None].
| ) | ||
| # Adding permissions to all catalogs (and all their schemas) can take a long | ||
| # time (minutes, while importing a chart, eg). If the database does not | ||
| # support cross-catalog queries (like RDS or Postgres), and the |
There was a problem hiding this comment.
Based on @arafoperata's feedback, we probably want to say "like Postgres" as it's not tied to RDS
Vitor-Avila
left a comment
There was a problem hiding this comment.
LGTM! Thanks for working on this improvement
There was a problem hiding this comment.
I've tested your changes and the issue is still occurring. It seems there are two different places where all catalogs are iterated. Once is in sync_permissions, but the other happens here.
This gets invoked on the CreateDatabaseCommand.
A similar change is required there. Is there any harm in moving the logic to return only the default catalog into the underlying get_all_catalog_names method(superset/models/core.py)?
(cherry picked from commit d88cba9)
SUMMARY
For performance reasons, change the
SyncPermissionsCommandto only sync permissions for non-default catalogs when at least one of these conditions is true:This means that for a database like RDS or Postgres, when we sync the permissions we will use only the default catalog, unless multi-catalog is enabled.
Fixes #32993.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A
TESTING INSTRUCTIONS
Added tests.
ADDITIONAL INFORMATION