Skip to content
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

fix Context loss when async invoke issue#13666 #15192

Open
wants to merge 4 commits into
base: 3.3
Choose a base branch
from

Conversation

MaxChen1123
Copy link

@MaxChen1123 MaxChen1123 commented Mar 2, 2025

What is the purpose of the change?

to fix issue #13666 in Dubbo Protocol (still has this issue in Triple)

How

  1. make it not check whether the map in RpcContextAttachment is empty (cuz it may be changed)
  2. write the ServerResponseContext in the future callback to make sure the operation to the context has already done

Checklist

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

@codecov-commenter
Copy link

codecov-commenter commented Mar 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.79%. Comparing base (3e5216f) to head (021eee9).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #15192      +/-   ##
============================================
+ Coverage     60.78%   60.79%   +0.01%     
- Complexity    10890    10894       +4     
============================================
  Files          1885     1885              
  Lines         86072    86077       +5     
  Branches      12892    12891       -1     
============================================
+ Hits          52319    52334      +15     
+ Misses        28306    28296      -10     
  Partials       5447     5447              
Flag Coverage Δ
integration-tests 33.14% <100.00%> (+0.06%) ⬆️
samples-tests 29.16% <100.00%> (-0.04%) ⬇️
unit-tests 59.00% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EarthChen
Copy link
Member

Please write some tests to verify the current changes.

@MaxChen1123
Copy link
Author

@EarthChen PTAL

// this is to fix https://github.com/apache/dubbo/issues/13666
this.responseFuture = this.responseFuture.thenApply((appResponse) -> {
RestoreContext tempStoredContext = RpcContext.clearAndStoreContext();
this.storedContext.restore();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore here might impact performance

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just get the serverResponseLocal in storedContext directly? Or maybe we can have a flag in the RpcContext, once the user pass context into a thread, they should manually set this flag to true, then we will check the flag to decide whether add this thenApply or not. I'm not sure which one is better. @AlbumenJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants