[#8662] Fix(core): Correctly cache entities with a relationType#8695
[#8662] Fix(core): Correctly cache entities with a relationType#8695keepConcentration wants to merge 1 commit intoapache:mainfrom
Conversation
| * @param newEntities The new entities to sync to the cache. | ||
| */ | ||
| private void syncEntitiesToCache(EntityCacheRelationKey key, List<Entity> newEntities) { | ||
| if (key.relationType() != null) return; |
There was a problem hiding this comment.
So, is it by design that we will not cache the relation data?
There was a problem hiding this comment.
It's supposed to be a deliberate design. @xunliu can you help to verify it?
There was a problem hiding this comment.
Yeah, that also puzzles me.
There was a problem hiding this comment.
Accordingly to the code, if if (key.relationType() != null) return; exists, we will not cache all entities associated with the relation, and the code looks quite weird.
There was a problem hiding this comment.
I can assure you that this is specifically designed in the current code base. If we enable caching data for relational operations, something will be wrong with the current cache layer.
|
@keepConcentration |
Thank you for letting me know. I will review the issue and provide a fix within this week. |
df26109 to
244d694
Compare
Hi, @yuqi1129 Thank you. |
244d694 to
1e0d32b
Compare
Please closely watch the failure test cases in the CI. |
It seems that intentionally not caching relational data is a design choice. Based on PR #8297, specifically the commit fba3b80 (Disable cache multi-layer relation entity), this behavior was deliberately added. |
I think so, and we can close this PR if it's hard to move on. |
Thanks for confirming. |
What changes were proposed in this pull request?
This PR addresses an issue in
CaffeineEntityCache.javawhere entities with a non-nullrelationTypewere not being cached as intended.The problem was traced to a
returnstatement in thesyncEntitiesToCachemethod that incorrectly prevented the caching of relation-based data.This change removes the aforementioned statement.
Why are the changes needed?
The previous behavior caused the cache to be bypassed for these operations, leading to unnecessary backend requests and preventing intended performance benefits. This fix ensures the caching mechanism now operates as designed.
Fix: #8662
Does this PR introduce any user-facing change?
No user-facing changes.
How was this patch tested?
Executed existing unit tests.
Added a new unit test (
testPutAndMergeWithRelationType) to verify that the fix works as expected.