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

网络异常时,BeatReactor 心跳线程会中断,导致dubbo网络恢复后服务注册信息无法自动重新注册 #5291

Closed
bestpayAmes opened this issue Apr 7, 2021 · 10 comments · Fixed by #5410
Labels
contribution welcome kind/enhancement Category issues or prs related to enhancement.
Milestone

Comments

@bestpayAmes
Copy link

The exception of BeatReactor ‘s BeatTask catched is wrong,when the dns can't work,the beat will suspend;
when unkownHost ,the nacos heat thread will interrupt;dubbo 's register info will be no recovery ;

dns不能工作时,com.alibaba.nacos.client.naming.beat.BeatReactor.BeatTask#run里会抛出非NacosException的异常,导致心跳任务停止,dns恢复后dubbo注册的服务不能恢复;

@realJackSun
Copy link
Collaborator

您使用的nacos版本号,以及dubbo的版本号是?

@bestpayAmes
Copy link
Author

nacos 1.4.1 ,dubbo 2.7.8
@JackSun-Developer

@KomachiSion
Copy link
Collaborator

能麻烦提供下,是哪一行,抛出了异常?

@bestpayAmes
Copy link
Author

你跑个demo,然后吧而网线拔了,就能复现

@haoyann
Copy link
Collaborator

haoyann commented Apr 12, 2021

@bestpayAmes
Hi,我用nacos 1.4.1没有复现呢,这是com.alibaba.nacos.client.naming.net.NamingProxy#callServer客户端发起请求的地方,我把网络断开,异常这里也捕获住了。
image
BeatTask 也能捕获这个异常。
image
重新连接网络之后,心跳也能恢复正常。你能提供一下是在哪里抛出的什么异常吗?

@bestpayAmes
Copy link
Author

at com.alibaba.nacos.common.utils.IPUtil.splitIPPortStr(IPUtil.java:152) ~[nacos-common-1.4.1.jar:?]
at com.alibaba.nacos.common.utils.IPUtil.containsPort(IPUtil.java:119) ~[nacos-common-1.4.1.jar:?]
at com.alibaba.nacos.client.naming.net.NamingProxy.callServer(NamingProxy.java:595) ~[nacos-client-1.4.1.jar:?]
at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:526) ~[nacos-client-1.4.1.jar:?]
at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:498) ~[nacos-client-1.4.1.jar:?]
at com.alibaba.nacos.client.naming.net.NamingProxy.sendBeat(NamingProxy.java:433) ~[nacos-client-1.4.1.jar:?]
at com.alibaba.nacos.client.naming.beat.BeatReactor$BeatTask.run(BeatReactor.java:153) [classes/:?]

@bestpayAmes
Copy link
Author

我用的是域名

@bestpayAmes
Copy link
Author

问题描述里写了dns的

@haoyann
Copy link
Collaborator

haoyann commented Apr 13, 2021

@bestpayAmes 好的,谢谢!

@KomachiSion
Copy link
Collaborator

Fixed by #4802 .

but we also can enhance it by catch Exception in BeatTask like

            } catch (NacosException ex) {
                NAMING_LOGGER.error("[CLIENT-BEAT] failed to send beat: {}, code: {}, msg: {}",
                        JacksonUtils.toJson(beatInfo), ex.getErrCode(), ex.getErrMsg());
            } catch (Exception unknownEx) {
                XXX
            } finally {
            executorService.schedule(new BeatTask(beatInfo), nextTime, TimeUnit.MILLISECONDS);
}

@KomachiSion KomachiSion added kind/enhancement Category issues or prs related to enhancement. and removed kind/research labels Apr 19, 2021
@KomachiSion KomachiSion linked a pull request Apr 20, 2021 that will close this issue
5 tasks
KomachiSion pushed a commit that referenced this issue Apr 20, 2021
* enhancement BeatTask always execute

* revert useless modify
@KomachiSion KomachiSion modified the milestones: 2.0.2, 1.4.2 Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants