-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
[dubbo 4458] doRefer in RestProtocol may cause OOM #4629
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4629 +/- ##
===========================================
+ Coverage 63.48% 63.99% +0.5%
- Complexity 451 452 +1
===========================================
Files 789 769 -20
Lines 34721 33186 -1535
Branches 5422 5231 -191
===========================================
- Hits 22044 21238 -806
+ Misses 10151 9525 -626
+ Partials 2526 2423 -103
Continue to review full report at Codecov.
|
@finalcola I am not persuaded that the current solution is better than the original. The reason is, I believe 'connection manager' plus 'connection monitor' will reuse and recycle the client. The potential OOM issue may caused by 'connection manager' is not used when the client is created, which has in fact been fixed by you with another pull request: #4614 |
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.
not sure this pull request is necessary.
#4614 will clear HTTPConnection, but RestProtocol will keep too much client(ResteasyClient) reference which makes these ResteasyClient instance can't be GC. |
I see. In your solution, when will ResteasyClient be recycled? |
a second thought: If I don't misunderstand, there's no way to recycle the clients, even if they are now saved in a map. This may lead to a potential problem, which is, the underlaying connection can be closed by connection manager (see connection monitor). If this happens, this will lead to invocation failure since the resteasy client maintained in the map doesn't have lifcecycle management. Should we simply create Resteasy client every time and then drop it? I think it is not expensive since the connection will be reused, what do you think? Or should we maintain the client in weak hash map instead? |
The previous implementation was to use a List to collect clients, but add client only, never remove. Now clients are saved in map which means they are in use, and old client will be remove and close. When doRefer happens, will create a new client for this url. @beiwei30 |
could you pls. point out when the client will be removed from the map? @finalcola |
it will not remove. My original idea was that each existing url would generate only one client(previous implementation using Sync List will add client everytime), because It is not clear whether the client corresponding to the url is still in use. maybe sync WeakHashMap can solve it, but it dose not pass the travis-ci in JDK 11. |
now, i use WeakRefence to hold client |
@beiwei30 could you please have a look, if there are any problems |
|
||
public void addConnectionManager(String key, PoolingHttpClientConnectionManager connectionManager) { | ||
connectionManagers.put(key, connectionManager); | ||
// connectionManagers.add(connectionManager); |
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.
remove unuse comment
@finalcola Hi, thanks for your contribution. Please merge the latest master branch to resolve confilcts. |
Close for long time no response. Please feel free to reopen if you have any question. If you think these changes still useful in the latest master branch, please submit a new pull request. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4629 +/- ##
============================================
+ Coverage 63.48% 63.99% +0.50%
- Complexity 451 452 +1
============================================
Files 789 769 -20
Lines 34721 33186 -1535
Branches 5422 5231 -191
============================================
- Hits 22044 21238 -806
+ Misses 10151 9525 -626
+ Partials 2526 2423 -103 ☔ View full report in Codecov by Sentry. |
What is the purpose of the change
#4458 (comment)
Brief changelog
XXXXX
Verifying this change
XXXXX
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false
&mvn clean test-compile failsafe:integration-test
to make sure unit-test and integration-test pass.