开发者社区 > 云原生 > 正文

当运行shutdown hook时,仍然可以接收来自使用者的一些新请求

当运行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&timestamp=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&timestamp=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&timestamp=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

展开
收起
大圣东游 2023-05-11 16:39:35 206 0
1 条回答
写回答
取消 提交回答
  • 注册中心推送是有时延的,在注册中心推送完成前还会有调用。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

    2023-05-12 10:32:33
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载