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 FailbackClusterInvoker one risk of memory leak #2425 #2822

Merged
merged 27 commits into from
Dec 25, 2018

Conversation

wangweiufofly
Copy link
Contributor

1.limit the size of the map,default is 1000. can config by key failcapacity
2.retry period,default is 100.can config by key retries.
3.shutdown the timer when destroyed

The issues:
#2425

@codecov-io
Copy link

codecov-io commented Nov 23, 2018

Codecov Report

Merging #2822 into master will decrease coverage by 0.02%.
The diff coverage is 70%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2822      +/-   ##
==========================================
- Coverage   64.38%   64.35%   -0.03%     
==========================================
  Files         584      584              
  Lines       26084    26111      +27     
  Branches     4559     4564       +5     
==========================================
+ Hits        16795    16805      +10     
- Misses       7111     7122      +11     
- Partials     2178     2184       +6
Impacted Files Coverage Δ
...c/main/java/org/apache/dubbo/common/Constants.java 88.88% <ø> (ø) ⬆️
...bo/rpc/cluster/support/FailbackClusterInvoker.java 76.19% <70%> (-10.3%) ⬇️
.../apache/dubbo/qos/protocol/QosProtocolWrapper.java 69.23% <0%> (-12.83%) ⬇️
.../remoting/transport/netty4/NettyClientHandler.java 75% <0%> (-11.12%) ⬇️
...che/dubbo/remoting/transport/mina/MinaChannel.java 43.42% <0%> (-10.53%) ⬇️
...in/java/org/apache/dubbo/common/utils/JVMUtil.java 73.58% <0%> (-7.55%) ⬇️
...onfig/spring/extension/SpringExtensionFactory.java 78.04% <0%> (-7.32%) ⬇️
...e/dubbo/remoting/transport/netty/NettyChannel.java 57.64% <0%> (-4.71%) ⬇️
...src/main/java/org/apache/dubbo/common/Version.java 49.41% <0%> (-0.59%) ⬇️
...apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java 66.66% <0%> (+0.83%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a35f942...ad6114e. Read the comment docs.

@carryxyh carryxyh self-requested a review November 23, 2018 04:17
Copy link
Member

@carryxyh carryxyh left a comment

Choose a reason for hiding this comment

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

Would u mind add some ut such as verify that the new configuration is in effect in the URL.

@@ -139,6 +139,10 @@

public static final int DEFAULT_RETRIES = 2;

public static final int DEFAULT_FAIL_CAPACITY_SIZE = 1000;
Copy link
Member

Choose a reason for hiding this comment

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

  1. DEFAULT_FAIL_CAPACITY_SIZE maybe changed to DEFAULT_FAILBACK_TASKS
    2.1000 is to large to us. maybe 100 is enough.
    :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I've changed it.


private final ConcurrentMap<Invocation, AbstractClusterInvoker<?>> failed = new ConcurrentHashMap<>();
private volatile ScheduledFuture<?> retryFuture;
private final int failCapacitySize;
Copy link
Member

Choose a reason for hiding this comment

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

maybe 'failbackTasks'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I've changed it.

@carryxyh
Copy link
Member

@beiwei30 @chickenlj
Would u pls have a look?

@carryxyh
Copy link
Member

Hi, @wangweiufofly
I think we should add a ut for this feature.
We should test the size of failback tasks and the retry times. :)

@carryxyh carryxyh self-assigned this Dec 20, 2018
@wangweiufofly
Copy link
Contributor Author

Hi, @wangweiufofly
I think we should add a ut for this feature.
We should test the size of failback tasks and the retry times. :)

test case completed

invoker.retryFailed();// when retry the invoker which get from failed map already is not the mocked invoker,so
// invoker.retryFailed();// when retry the invoker which get from failed map already is not the mocked invoker,so
//Ensure that the main thread is online
CountDownLatch countDown = new CountDownLatch(1);
Copy link
Member

Choose a reason for hiding this comment

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

I think u should assert that the logger contains the specific msg.

invoker.invoke(invocation);
assertEquals(1, LogUtil.findMessage("Failback to invoke"));
LogUtil.stop();
}

@Test()
public void testRetryFailed() {
public void testARetryFailed() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

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

Could u pls tell us why u rename the method and why u add the FixMethodOrder annotation?
:)

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.

3 participants