-
Notifications
You must be signed in to change notification settings - Fork 560
Avoid adding values to cache if the current value is the same as adding value #6673
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
Conversation
PR builder started |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6673 +/- ##
============================================
+ Coverage 47.73% 48.69% +0.96%
+ Complexity 16806 16687 -119
============================================
Files 1937 1881 -56
Lines 113988 110677 -3311
Branches 21504 20999 -505
============================================
- Hits 54416 53898 -518
+ Misses 52284 49510 -2774
+ Partials 7288 7269 -19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR builder completed |
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.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/14357216988
a9af38e
to
e0d923c
Compare
This PR is dependent on a kernel PR. Hence until a Kernel release happens this will not be merged. |
PR builder started |
PR builder completed |
PR builder started |
PR builder completed |
PR builder started |
PR builder completed |
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.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/15179735905
Claim claim = (Claim) o; | ||
return Objects.equals(claimDialectURI, claim.claimDialectURI) | ||
&& Objects.equals(claimURI, claim.claimURI) | ||
&& Objects.equals(claimProperties, claim.claimProperties); |
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.
Do maps equal check work with Objects.equals? Please double check
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.
Yes. Map.equals checks for content equality.
@@ -0,0 +1,140 @@ | |||
package org.wso2.carbon.identity.claim.metadata.mgt.model; |
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.
License headers
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.
Check other new files as well
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.
Addressed with 9549119
assertEquals(localClaim.getMappedAttributes().size(), 1, "Mapped attribute should be added correctly"); | ||
assertEquals(localClaim.getMappedAttributes().get(0).getAttributeName(), "email", "Mapped attribute name should match"); | ||
} | ||
} |
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.
add a new line
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.
Addressed with 9549119
} | ||
|
||
try { | ||
startTenantFlow(tenantId); |
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.
Will the startTenantFlow work with both tenantId and tenantDomain?? Please check
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.
it does
Line 372 in 20aa45a
private void startTenantFlow(int tenantId) { |
startTenantFlow(tenantId); | ||
Cache<K, V> cache = getBaseCache(); | ||
if (cache != null) { | ||
cache.putIfNoDuplicate(key, entry); |
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 a method given by baseCache or something newly implemented?
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.
it's newly implemented
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.
|
Purpose
When there is a cache miss the value is added to the cache. But in a clustered environment many nodes may simultaneously read the initial value as null and then try to add the value. But at the time of adding the value, the first one to complete adding the value succeeds but other processes proceed to update the value instead of adding the value.
However while adding doesn't invalidate cache, updating does. But since if the new value is the same as the existing one, there's no need to update the value and then invalidate the cache. This behaviour causes unnecessary cache invalidations in clustered environments. This then leads to unnecessary db reads to retrieve the same value again and again.
Changes of this PR performs an equality check between the new value and the value in the cache and skips updating if the values are the same. This avoids unnecessary cache invalidations.
Related Issue/s
Dependent on