Eliminate redundant metastore lookups when resolving principal roles#5020
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes DefaultAuthenticator.resolvePrincipalRoles to avoid per-grant metastore lookups by using the preloaded securable entities already returned from loadGrantsToGrantee, reducing authenticated-request overhead for principals with many role grants.
Changes:
- Resolve principal role names from
LoadGrantsResult.getEntitiesAsMap()instead of callingloadEntity(...)for each grant record. - Add a Quarkus test to ensure role resolution does not trigger per-grant
loadEntity(..., PRINCIPAL_ROLE)calls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultAuthenticator.java | Switches role-entity resolution to use the preloaded entities map from LoadGrantsResult to eliminate redundant metastore calls. |
| runtime/service/src/test/java/org/apache/polaris/service/auth/DefaultAuthenticatorTest.java | Adds a regression test that verifies role resolution does not perform per-grant role entity loads. |
ayushtkn
force-pushed
the
defaultauthenticator
branch
from
July 9, 2026 14:47
67ae7b2 to
05d86ac
Compare
nandorKollar
approved these changes
Jul 10, 2026
adutra
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DefaultAuthenticator.resolvePrincipalRolesruns on every authenticated request and already callsloadGrantsToGrantee, which returns both grant records and the resolved securable entities in a single bulk metastore read. The authenticator was ignoring those pre-loaded entities and callingloadEntityonce per grant record, so a principal withNroles caused1+Nmetastore reads per auth instead of one. This change resolves role names fromLoadGrantsResult.getEntitiesAsMap(), matching the pattern already used inPolarisAdminService, while preserving existing behavior: missing entities and non-PRINCIPAL_ROLE securables are still filtered out, and requested-role filtering is unchanged.Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)