-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CORE-137 Optimize filter resources #1577
Conversation
private val publicResourcesCache: java.util.Map[ResourceTypeName, Seq[FilterResourcesResult]] = | ||
Collections.synchronizedMap(new PassiveExpiringMap(1, TimeUnit.HOURS)) | ||
private val publicResourcesCache: ConcurrentMap[ResourceTypeName, Seq[FilterResourcesResult]] = | ||
Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build[ResourceTypeName, Seq[FilterResourcesResult]]().asMap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched to a concurrent hashmap implementation because synchronized maps do not allow concurrent reads. Even if the reads are fast, synchronized can lead to jam ups and interference between different resource types.
If the role:action association exists both as static config and in the db, does this change lead to a possible inconsistency?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ok to me. I have to admit I am too unfamiliar with it to be very confident. I get the high-level design change and that sounds good.
Does the contract test failure indicate a real change in functionality?
@@ -116,7 +116,10 @@ class ResourceService( | |||
samRequestContext | |||
) | |||
} | |||
} yield upsertedPolicy | |||
} yield { | |||
logger.info(s"Upserted policy $fullyQualifiedPolicyId") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intentional or a leftover from development?
No, step 1 in your list is not how it works. The role is assigned to the user, not the role's actions. The role:action association stored in the database is only update on startup to match what is in config. |
Got it - thank you! |
Quality Gate passedIssues Measures |
Ticket: https://broadworkbench.atlassian.net/browse/CORE-137
What:
The query implemented in
PostgresAccessPolicyDAO.filterPrivateResources
has been highlighted by query insights as far and away the biggest load by time on the database. It is called on average 1.1 million times per day! It is the query behind the api to list user resources. Around the beginning of October, we also noticed in dev that this query was causing stability issues because the AoU user had access to too many google-project resources. Those were cleaned up but the vulnerability remains.How:
There were 2 main observations:
Overall, the workhorse query is much smaller in terms of joins.
PR checklist