You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "zsewasdsdsd (via GitHub)" <gi...@apache.org> on 2026/10/13 12:31:38 UTC

[PR] fix: update entries already admitted to LRU2Cache [dubbo]

zsewasdsdsd opened a new pull request, #16503:
URL: https://github.com/apache/dubbo/pull/16503

   ## Summary
   
   Fixes #16500.
   
   This PR fixes an issue in `LRU2Cache.put()` where updating a key that has already been promoted to the main cache does not replace its existing value.
   
   ## Problem
   
   `LRU2Cache` uses a two-write admission policy:
   
   1. The first `put()` records the key in the history cache (`preCache`).
   2. The second `put()` promotes the key into the main cache.
   3. Subsequent `put()` calls should update the existing cached value.
   
   However, the current implementation only checks whether the key exists in `preCache`. Once a key has been promoted, it is removed from `preCache`, causing subsequent updates to be treated as new entries instead of updating the main cache.
   
   As a result, callers may continue receiving stale cached values.
   
   ## Changes
   
   - Check whether the key already exists in the main cache before applying the two-write admission policy.
   - Update existing entries while preserving the previous-value return behavior.
   - Preserve the existing locking mechanism and LRU eviction order.
   - Add regression tests covering promoted-entry updates, LRU ordering, and null-valued entries.
   
   ## Verification
   
   **RED — Before the fix**
   - Reproduced the issue against the original upstream Java implementation.
   - 3 expected regression failures; 1 existing-behavior check passed.
   
   **GREEN — After the fix**
   - All 4 standalone regression checks passed.
   - Ran `LRU2CacheTest` using Maven on Windows with Java 21.
   - Tests run: **7**
   - Failures: **0**
   - Errors: **0**
   - Skipped: **0**
   - Maven result: **BUILD SUCCESS**
   
   No full-repository test suite or distributed RPC integration tests were run.
   
   ## Impact
   
   This change ensures that already-admitted cache entries can be updated correctly without changing the admission policy for new keys or introducing new dependencies.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] fix: update entries already admitted to LRU2Cache [dubbo]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #16503:
URL: https://github.com/apache/dubbo/pull/16503#issuecomment-6149488889

   ## [Codecov](https://app.codecov.io/gh/apache/dubbo/pull/16503?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 58.65%. Comparing base ([`ae809de`](https://app.codecov.io/gh/apache/dubbo/commit/ae809de2fc81b408194240965eb20bf27e6971df?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`d419b72`](https://app.codecov.io/gh/apache/dubbo/commit/d419b720c7b1333548777e87f0ad04dd92bcc0bd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##                3.3   #16503      +/-   ##
   ============================================
   - Coverage     58.90%   58.65%   -0.25%     
     Complexity       15       15              
   ============================================
     Files          1953     1953              
     Lines         89278    89261      -17     
     Branches      13476    13392      -84     
   ============================================
   - Hits          52592    52359     -233     
   - Misses        30993    31157     +164     
   - Partials       5693     5745      +52     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/dubbo/pull/16503/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [unit-tests-java11](https://app.codecov.io/gh/apache/dubbo/pull/16503/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit-tests-java17](https://app.codecov.io/gh/apache/dubbo/pull/16503/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit-tests-java21](https://app.codecov.io/gh/apache/dubbo/pull/16503/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `58.65% <100.00%> (+0.03%)` | :arrow_up: |
   | [unit-tests-java25](https://app.codecov.io/gh/apache/dubbo/pull/16503/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit-tests-java8](https://app.codecov.io/gh/apache/dubbo/pull/16503/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/dubbo/pull/16503?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org