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

Direct return when the server goes down unnormally. #2185

Merged
merged 34 commits into from
Aug 23, 2018

Conversation

carryxyh
Copy link
Member

@carryxyh carryxyh commented Aug 4, 2018

Keep the unfinished request in every channel.
When the server goes down un-normally, return the unfinished requests directly.
The current way is to wait until timeout.

issue:
#2184

@diecui1202
Copy link

@carryxyh please check the travis ci failure.

@carryxyh
Copy link
Member Author

carryxyh commented Aug 6, 2018

@diecui1202
yeah. maybe still some problems. I will try to fix them later.

@carryxyh
Copy link
Member Author

carryxyh commented Aug 7, 2018

@diecui1202
Already fix unit test.

@codecov-io
Copy link

codecov-io commented Aug 7, 2018

Codecov Report

Merging #2185 into master will increase coverage by 0.23%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2185      +/-   ##
============================================
+ Coverage     54.32%   54.55%   +0.23%     
- Complexity     5112     5152      +40     
============================================
  Files           559      570      +11     
  Lines         24996    25057      +61     
  Branches       4456     4459       +3     
============================================
+ Hits          13578    13671      +93     
+ Misses         9386     9345      -41     
- Partials       2032     2041       +9
Impacted Files Coverage Δ Complexity Δ
...a/org/apache/dubbo/remoting/exchange/Response.java 92.1% <ø> (ø) 18 <0> (ø) ⬇️
...c/main/java/org/apache/dubbo/remoting/Channel.java 0% <0%> (ø) 0 <0> (?)
...dubbo/remoting/exchange/support/DefaultFuture.java 7.09% <0%> (-0.16%) 2 <0> (ø)
...pache/dubbo/remoting/transport/AbstractClient.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...exchange/support/header/HeaderExchangeHandler.java 29.68% <0%> (-0.48%) 10 <0> (ø)
...ache/dubbo/remoting/transport/AbstractChannel.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ache/dubbo/remoting/p2p/support/AbstractGroup.java 45.45% <0%> (-11.37%) 7% <0%> (-1%)
...ubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java 41.66% <0%> (-8.34%) 3% <0%> (ø)
...rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java 51.89% <0%> (-3.8%) 11% <0%> (-2%)
...bo/remoting/transport/netty/NettyCodecAdapter.java 53.12% <0%> (-1.57%) 3% <0%> (ø)
... and 14 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 70e1e62...22948cc. Read the comment docs.

@@ -117,6 +117,7 @@ public void test_NoInvokers() throws Exception {
}

@Test
@Ignore

Choose a reason for hiding this comment

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

Why ignore this test case ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't ignore this.
Maybe it is a outdated content ?

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.*;

Choose a reason for hiding this comment

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

It's not a good practice to import *

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, fix it soon.

Copy link
Member

Choose a reason for hiding this comment

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

import * can't pass check-style when submitting a PR


private Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
private ProxyFactory proxy = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();

@Ignore
Copy link
Member

Choose a reason for hiding this comment

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

there is an ignore too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fix it soon :)

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.*;
Copy link
Member

Choose a reason for hiding this comment

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

import * can't pass check-style when submitting a PR

@carryxyh
Copy link
Member Author

carryxyh commented Aug 8, 2018

@kimmking
@diecui1202
Fix the unit test and import *.
Review again pls :)

@chickenlj
Copy link
Contributor

I am not sure if Channel keeps the status of requests (UN_FINISH_REQUESTS_MAP) is a good practice. For one reason, Channel is equivalent for both client and server, but only the client cares about the status of requests.

Maybe keep the status of requests on DefaultFuture can be better?

@zonghaishang
Copy link
Member

I agree with Li Jun’s point of view.
Server graceful shutdown processing mechanism:

1. Unregister service from registry
2. Notify the client of the readonly event in real time(readonly event)
3. If the client settings timeout is not appropriate, the server will automatically close the connection, and the client will also receive notifications or timeouts.

The current elegant downtime work is relatively good.

@carryxyh
Copy link
Member Author

Maybe keep the status of requests on DefaultFuture can be better?
Ok, that is more clearly.
Fix soon :)

@diecui1202 diecui1202 added the status/waiting-for-feedback Need reporters to triage label Aug 17, 2018
*
* @param channel
*/
public static void closeChannel(Channel channel) {
Copy link
Member

Choose a reason for hiding this comment

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

I guess we may possibly avoid introducing UNFINISHED_REQUESTS by doing this:

        for (long id : CHANNELS.keySet()) {
            if (channel.equals(CHANNELS.get(id))) {
                DefaultFuture future = getFuture(id);
                if (!future.isDone()) {
                    Response disconnectResponse = new Response(r.getId());
                    disconnectResponse.setStatus(Response.CHANNEL_INACTIVE);
                    disconnectResponse.setErrorMessage("Channel " + channel + " is inactive. Directly return the unFinished request.");
                    DefaultFuture.received(channel, disconnectResponse);
                }
            }
        }

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks good to me! I’ll fix it soon.

@beiwei30 beiwei30 merged commit c6fd684 into apache:master Aug 23, 2018
@carryxyh carryxyh deleted the server-down branch August 23, 2018 08:45
stateIs0 added a commit to stateIs0/incubator-dubbo that referenced this pull request Dec 13, 2019
* Keep the unfinished request in every channel.
When the server goes down un-normally, return the unfinished requests directly.
The current way is to wait until timeout.

* default method

* direct return unfinished requests when remote inactive or disconnect

* direct return unfinished requests when remote inactive or disconnect

* name and doc

* name and doc

* fix unit test

* fix unit test

* fix unit test

* close heartbeat to fix unit test

* sth test

* sth test

* sth test

* sth test

* close when client close

* fix unit test

* fix unit test

* fix unit test

* ignore remote invoke unit test

* don't clear request when channelInactive

* replace import *

* remove unuse import

* optimize

* optimize

* fix ci failed

* fix ci failed

* fix ci failed

* fix ci failed

* fix ci failed

* fix ci failed

* fix ci failed

* optimize unfinished request keeper

* rebase onto master

* fix review code

(cherry picked from commit c6fd684)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-for-feedback Need reporters to triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants