当运行shutdown hook时,仍然有来自comsumer的一些新请求,我的应用程序部署在Kubernetes上
这是我的日志:
2022-09-27 21:44:37.965 [RID:] [traceId:] [DubboShutdownHook] INFO o.a.dubbo.config.DubboShutdownHook [DubboShutdownHook.java:59] [DUBBO] Run shutdown hook now., dubbo version: 3.0.8, current host: xxxx
2022-09-27 21:44:37.965 [RID:] [traceId:] [Thread-25] WARN c.a.n.c.http.HttpClientBeanHolder [HttpClientBeanHolder.java:108] [HttpClientBeanHolder] Start destroying common HttpClient
2022-09-27 21:44:37.965 [RID:] [traceId:] [DubboShutdownHook] INFO o.a.dubbo.rpc.model.FrameworkModel [FrameworkModel.java:294] [DUBBO] Reset global default application from Dubbo Application1.1 to null, dubbo version: 3.0.8, current host: xxxx
2022-09-27 21:44:37.965 [RID:] [traceId:] [DubboShutdownHook] INFO o.a.d.c.d.DefaultApplicationDeployer [DefaultApplicationDeployer.java:981] [DUBBO] Dubbo Application1.1 is stopping., dubbo version: 3.0.8, current host: xxxxx
2022-09-27 21:44:37.966 [RID:] [traceId:] [Thread-28] WARN c.a.nacos.common.notify.NotifyCenter [NotifyCenter.java:136] [NotifyCenter] Start destroying Publisher
2022-09-27 21:44:38.220 [RID:] [traceId:] [Thread-28] WARN c.a.nacos.common.notify.NotifyCenter [NotifyCenter.java:153] [NotifyCenter] Destruction of the end
2022-09-27 21:44:38.220 [RID:] [traceId:] [DubboShutdownHook] INFO o.a.d.r.support.RegistryManager [RegistryManager.java:98] [DUBBO] Close all registries [xxxx], dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
2022-09-27 21:44:38.220 [RID:] [traceId:] [Thread-25] WARN c.a.n.c.http.HttpClientBeanHolder [HttpClientBeanHolder.java:114] [HttpClientBeanHolder] Destruction of the end
2022-09-27 21:44:38.221 [RID:ee105389-4bf6-4cd7-a2ae-289067769217] [traceId:] [Dubbo-global-shared-handler-thread-6] INFO there is new request log
2022-09-27 21:44:38.223 [RID:] [traceId:] [SpringApplicationShutdownHook] INFO o.a.d.c.deploy.DefaultModuleDeployer [DefaultModuleDeployer.java:288] [DUBBO] Dubbo Module[1.1.1] is stopping., dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
2022-09-27 21:44:38.256 [RID:] [traceId:] [SpringApplicationShutdownHook] WARN o.a.d.r.support.RegistryManager [RegistryManager.java:127] [DUBBO] All registry instances have been destroyed, failed to fetch any instance. Usually, this means no need to try to do unnecessary redundant resource clearance, all registries has been taken care of., dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
2022-09-27 21:44:38.307 [RID:] [traceId:] [SpringApplicationShutdownHook] WARN o.a.d.r.support.RegistryManager [RegistryManager.java:127] [DUBBO] All registry instances have been destroyed, failed to fetch any instance. Usually, this means no need to try to do unnecessary redundant resource clearance, all registries has been taken care of., dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
2022-09-27 21:44:38.307 [RID:ee105389-4bf6-4cd7-a2ae-289067769217] [traceId:] [Dubbo-global-shared-handler-thread-6] INFO there is a response
2022-09-27 21:44:38.342 [RID:] [traceId:] [SpringApplicationShutdownHook] WARN o.a.d.r.support.RegistryManager [RegistryManager.java:127] [DUBBO] All registry instances have been destroyed, failed to fetch any instance. Usually, this means no need to try to do unnecessary redundant resource clearance, all registries has been taken care of., dubbo version: 3.0.8, current host: xxxxx
2022-09-27 21:44:38.367 [RID:] [traceId:] [Dubbo-global-shared-handler-thread-10] WARN o.a.d.r.p.d.DecodeableRpcInvocation [DecodeableRpcInvocation.java:96] [DUBBO] Decode rpc invocation failed: Service xxxxx with version 0.0.0 not found, invocation rejected., dubbo version: 3.0.8, current host: xxx.xxx.xx.xx java.io.IOException: Service xxxxx with version 0.0.0 not found, invocation rejected. at org.apache.dubbo.remoting.transport.CodecSupport.checkSerialization(CodecSupport.java:166) at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:138) at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:93) at org.apache.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:57) at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:44) at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750)
2022-09-27 21:44:38.375 [RID:] [traceId:] [SpringApplicationShutdownHook] INFO o.a.d.registry.nacos.NacosRegistry [AbstractRegistry.java:371] [DUBBO] Unsubscribe: consumer://xxxx/xxxxx?application=xxxx&background=false&category=providers,configurators,routers&check=false&dubbo=2.0.2&group=xxxxx&interface=xxxxx&methods=xxx,xxx,xxx,xxx&pid=1&qos.enable=false&release=3.0.8&retries=0&side=consumer&sticky=false&timeout=10000×tamp=1664172675707, dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
2022-09-27 21:44:38.655 [RID:] [traceId:] [Dubbo-global-shared-handler-thread-11] WARN o.a.d.r.p.d.DecodeableRpcInvocation [DecodeableRpcInvocation.java:96] [DUBBO] Decode rpc invocation failed: Service xxxxx with version 0.0.0 not found, invocation rejected., dubbo version: 3.0.8, current host: xxx.xxx.xx.xx java.io.IOException: Service xxxxx with version 0.0.0 not found, invocation rejected. at org.apache.dubbo.remoting.transport.CodecSupport.checkSerialization(CodecSupport.java:166) at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:138) at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:93) at org.apache.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:57) at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:44) at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750)
2022-09-27 21:44:38.666 [RID:] [traceId:] [SpringApplicationShutdownHook] INFO o.a.d.registry.nacos.NacosRegistry [AbstractRegistry.java:371] [DUBBO] Unsubscribe: consumer://xxxx/xxxxx?application=xxxx&background=false&category=providers,configurators,routers&check=false&dubbo=2.0.2&group=xxxxx&interface=xxxxx&methods=xxx,xxxx&pid=1&qos.enable=false&release=3.0.8&retries=0&side=consumer&sticky=false&timeout=10000×tamp=1664172676045, dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
2022-09-27 21:44:38.676 [RID:] [traceId:] [Dubbo-global-shared-handler-thread-7] WARN o.a.d.r.p.d.DecodeableRpcInvocation [DecodeableRpcInvocation.java:96] [DUBBO] Decode rpc invocation failed: Service xxxxx with version 0.0.0 not found, invocation rejected., dubbo version: 3.0.8, current host: xxx.xxx.xx.xx java.io.IOException: Service xxxxx with version 0.0.0 not found, invocation rejected. at org.apache.dubbo.remoting.transport.CodecSupport.checkSerialization(CodecSupport.java:166) at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:138) at org.apache.dubbo.rpc.protocol.dubbo.DecodeableRpcInvocation.decode(DecodeableRpcInvocation.java:93) at org.apache.dubbo.remoting.transport.DecodeHandler.decode(DecodeHandler.java:57) at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:44) at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750)
2022-09-27 21:44:38.676 [RID:] [traceId:] [SpringApplicationShutdownHook] INFO o.a.d.registry.nacos.NacosRegistry [AbstractRegistry.java:371] [DUBBO] Unsubscribe: consumer://xxxxx/xxxxxx?application=xxxx&background=false&category=providers,configurators,routers&check=false&dubbo=2.0.2&group=xxxxx&interface=xxxxx&methods=xxxx,xxxx,xxxx&pid=1&qos.enable=false&release=3.0.8&retries=0&side=consumer&sticky=false&timeout=10000×tamp=1664172676295, dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
2022-09-27 21:44:38.678 [RID:] [traceId:] [SpringApplicationShutdownHook] INFO o.a.d.r.t.netty4.NettyChannel [NettyChannel.java:201] [DUBBO] Close netty channel [id: 0x19fddddb, L:/xxx.xxx.xx.xx:46910 - R:/xxx.xxx.xx.xx:20880], dubbo version: 3.0.8, current host: xxx.xxx.xx.xx
原提问者GitHub用户neverlaughtingboy
注册中心推送是有时延的,在注册中心推送完成前还会有调用。k8s 基于 post 脚本先调用 dubbo qos 的 offline 推送下线信息,等待一段时间后再关闭进程。
这个看你是 dubbo 接口作为流量入口还是 Spring web 作为流量入口,如果是 dubbo 入口的话通过 qos offline 可以先下线流量,如果通过 Spring web 入口的话就需要独立处理 shutdown hook
先 qos offline 摘掉 dubbo 流量,然后通过 -Ddubbo.shutdownHook.listenIgnore=true 实现 Spring web 的优雅下线。
后面的 shutdown hook 的 dubbo 在接下来的版本优化下。
原回答者GitHub用户AlbumenJ
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。