Closed wggy closed 3 years ago
补一张shutdown后的日志图片:
是不是自己程序的bug引起的,建议将日志信息打印的更为详细一点看下
触发shutdownhook肯定是收到了程序停止的信号,或者哪里主动调用了nacos的shutdown方法,你需要自己排查下。
而且从日志看,不仅是nacos shutdown了,连接池也shutdown了(nacos没有连接池引用)。所以肯定是你程序自己的问题,触发了shutdownhook。
2020-12-10 07:59:55.887 DEBUG 8525 --- [nio-8091-exec-4] org.hibernate.loader.Loader : Result set row: 0
2020-12-10 07:59:55.887 DEBUG 8525 --- [nio-8091-exec-4] org.hibernate.loader.Loader : Result row: EntityKey[com.gitee.sop.openapi.browser.entity.UsersEntity#15869307353321]
2020-12-10 07:59:55.888 DEBUG 8525 --- [nio-8091-exec-4] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2020-12-10 07:59:55.888 DEBUG 8525 --- [nio-8091-exec-4] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(473046285
java.lang.NullPointerException: null at com.alibaba.cloud.nacos.NacosServiceManager.nacosServiceShutDown(NacosServiceManager.java:115) ~[spring-cloud-starter-alibaba-nacos-discovery-2.2.3.RELEASE.jar!/:2.2.3.RELEASE] at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.close(NacosServiceRegistry.java:112) ~[spring-cloud-starter-alibaba-nacos-discovery-2.2.3.RELEASE.jar!/:2.2.3.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161] at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:339) [spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:273) [spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587) [spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559) [spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1092) [spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520) [spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1085) [spring-beans-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1061) [spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1030) [spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:170) [spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:949) [spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
2020-12-10 08:00:17.816 INFO 8525 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' 2020-12-10 08:00:17.821 DEBUG 8525 --- [extShutdownHook] io.lettuce.core.RedisChannelHandler : closeAsync() 2020-12-10 08:00:17.821 DEBUG 8525 --- [extShutdownHook] i.lettuce.core.protocol.DefaultEndpoint : [channel=0xd114962e, /172.32.33.81:35246 -> superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379, epid=0x1] closeAsync() 2020-12-10 08:00:17.827 DEBUG 8525 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler : [channel=0xd114962e, /172.32.33.81:35246 -> superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379, chid=0x1] channelInactive() 2020-12-10 08:00:17.828 DEBUG 8525 --- [extShutdownHook] io.lettuce.core.RedisClient : Initiate shutdown (100, 100, MILLISECONDS) 2020-12-10 08:00:17.829 DEBUG 8525 --- [ioEventLoop-4-1] i.lettuce.core.protocol.DefaultEndpoint : [channel=0xd114962e, /172.32.33.81:35246 -> superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379, epid=0x1] deactivating endpoint handler 2020-12-10 08:00:17.829 DEBUG 8525 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler : [channel=0xd114962e, /172.32.33.81:35246 -> superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379, chid=0x1] channelInactive() done 2020-12-10 08:00:17.830 DEBUG 8525 --- [ioEventLoop-4-1] i.l.core.protocol.ConnectionWatchdog : [channel=0xd114962e, /172.32.33.81:35246 -> superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379, last known addr=superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379] channelInactive() 2020-12-10 08:00:17.830 DEBUG 8525 --- [ioEventLoop-4-1] i.l.core.protocol.ConnectionWatchdog : [channel=0xd114962e, /172.32.33.81:35246 -> superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379, last known addr=superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379] Reconnect scheduling disabled 2020-12-10 08:00:17.831 DEBUG 8525 --- [ioEventLoop-4-1] io.lettuce.core.protocol.CommandHandler : [channel=0xd114962e, /172.32.33.81:35246 -> superbrowser-test.tvlcc1.ng.0001.cnn1.cache.amazonaws.com.cn/172.32.15.90:6379, chid=0x1] channelUnregistered() 2020-12-10 08:00:17.844 DEBUG 8525 --- [extShutdownHook] i.l.c.r.DefaultEventLoopGroupProvider : Release executor io.netty.channel.nio.NioEventLoopGroup@7774e262 2020-12-10 08:00:17.946 DEBUG 8525 --- [ioEventLoop-4-1] io.netty.buffer.PoolThreadCache : Freed 8 thread-local buffer(s) from thread: lettuce-nioEventLoop-4-1 2020-12-10 08:00:17.951 DEBUG 8525 --- [extShutdownHook] i.l.c.resource.DefaultClientResources : Initiate shutdown (0, 2, SECONDS) 2020-12-10 08:00:17.954 DEBUG 8525 --- [extShutdownHook] i.l.c.r.DefaultEventLoopGroupProvider : Initiate shutdown (0, 2, SECONDS) 2020-12-10 08:00:17.960 INFO 8525 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'browserPersistenceUnit' 2020-12-10 08:00:17.960 DEBUG 8525 --- [extShutdownHook] o.hibernate.internal.SessionFactoryImpl : HHH000031: Closing 2020-12-10 08:00:17.960 DEBUG 8525 --- [extShutdownHook] o.h.type.spi.TypeConfiguration$Scope : Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@1bca4ab3] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@1e008f36] 2020-12-10 08:00:17.960 DEBUG 8525 --- [extShutdownHook] o.h.s.i.AbstractServiceRegistryImpl : Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries 2020-12-10 08:00:17.962 DEBUG 8525 --- [extShutdownHook] o.h.b.r.i.BootstrapServiceRegistryImpl : Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries 2020-12-10 08:00:17.962 INFO 8525 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : Browser-HikariPool - Shutdown initiated... 2020-12-10 08:00:17.962 DEBUG 8525 --- [extShutdownHook] com.zaxxer.hikari.pool.HikariPool : Browser-HikariPool - Before shutdown stats (total=1, active=0, idle=1, waiting=0) 2020-12-10 08:00:17.964 DEBUG 8525 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : Browser-HikariPool - Closing connection com.mysql.cj.jdbc.ConnectionImpl@30370bb1: (connection evicted) 2020-12-10 08:00:17.964 DEBUG 8525 --- [extShutdownHook] com.zaxxer.hikari.pool.HikariPool : Browser-HikariPool - After shutdown stats (total=0, active=0, idle=0, waiting=0) 2020-12-10 08:00:17.965 INFO 8525 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : Browser-HikariPool - Shutdown completed. 2020-12-10 08:00:17.965 INFO 8525 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'sopPersistenceUnit' 2020-12-10 08:00:17.965 DEBUG 8525 --- [extShutdownHook] o.hibernate.internal.SessionFactoryImpl : HHH000031: Closing 2020-12-10 08:00:17.965 DEBUG 8525 --- [extShutdownHook] o.h.type.spi.TypeConfiguration$Scope : Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@1361a50e] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@36ac8a63] 2020-12-10 08:00:17.965 DEBUG 8525 --- [extShutdownHook] o.h.s.i.AbstractServiceRegistryImpl : Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries 2020-12-10 08:00:17.966 DEBUG 8525 --- [extShutdownHook] o.h.b.r.i.BootstrapServiceRegistryImpl : Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries 2020-12-10 08:00:17.966 INFO 8525 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : SOP-HikariPool - Shutdown initiated... 2020-12-10 08:00:17.966 DEBUG 8525 --- [extShutdownHook] com.zaxxer.hikari.pool.HikariPool : SOP-HikariPool - Before shutdown stats (total=1, active=0, idle=1, waiting=0) 2020-12-10 08:00:17.966 DEBUG 8525 --- [nnection closer] com.zaxxer.hikari.pool.PoolBase : SOP-HikariPool - Closing connection com.mysql.cj.jdbc.ConnectionImpl@3f34c2af: (connection evicted) 2020-12-10 08:00:17.967 DEBUG 8525 --- [extShutdownHook] com.zaxxer.hikari.pool.HikariPool : SOP-HikariPool - After shutdown stats (total=0, active=0, idle=0, waiting=0) 2020-12-10 08:00:17.971 INFO 8525 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : SOP-HikariPool - Shutdown completed.
确实是触发了shutdownHook,服务部署在aws云主机,nacos使用的是外网地址,不知道是否是心跳断开引起的shutdownHook
nacos 本身不会触发,如果你发现是NacosServiceRegistry触发的,请提issue到SCA社区,不过我建议你排查一下自己的逻辑,大概率是你自己的逻辑触发了shutdown或者是aws帮你kill了。
使用kill -15,在程序里addShutdownHook添加钩子后,在进入这个方法的时候就会去触发Naocos注销实例,其实我在这个方法中又等待30秒的,这个情况要如何处理啊?
我也碰到了这个问题 服务经常被shutdown,后面这个情况是怎么解决的?
我也遇到了这个问题,这是我个人在csdn上的分析, 感觉就是nacos的bug,https://blog.csdn.net/ycuzrz112280/article/details/119453697
我也碰到了,正在学springb-cloud-alibaba, 照着视频来的,也是过一会就自动挂掉
我也碰到了,微服务中只有一些业务API,然后就遭遇了宕机...... https://z3.ax1x.com/2021/10/22/56L1ld.png
同问
解决了么,怎么解决的啊
解决了么,怎么解决的啊
可以把你的java启动命令截图出来。我看下
我遇到的问题更奇怪,手动调用启动脚本服务能开住,不会掉,用Jenkins自动化走同样的脚本启动,服务就会先起来再挂掉
同问
当我们把项目部署到服务器上时,只有一直保持linux终端的连接才能够运行项目,当我们把连接软件Xshell或者Finalshell连接工具关掉时,项目也就停止运行。只要用了nohup命令,我们的项目就能够一直运行了,此时就实现了我们需求。
大概是因为这个原因 解决方式: 1.脚本启动 2.nohup启动
参考: https://blog.csdn.net/qq_45830276/article/details/126044645
Describe the bug A clear and concise description of what the bug is.
程序异常退出,启动一台服务,偶发shutdown springcloud服务挂掉,启动三台服务,同样偶发springcloud服务挂掉,且是同时挂掉!!!
下面是日志shutdownHook日志:
Expected behavior 2020-12-08 10:51:13.901 INFO 9163 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'Nacos-Watch-Task-Scheduler' 2020-12-08 10:51:13.913 INFO 9163 --- [extShutdownHook] c.a.c.n.registry.NacosServiceRegistry : De-registering from Nacos Server now... 2020-12-08 10:51:13.916 INFO 9163 --- [extShutdownHook] c.a.c.n.registry.NacosServiceRegistry : De-registration finished. 2020-12-08 10:51:24.266 WARN 9163 --- [extShutdownHook] o.s.b.f.support.DisposableBeanAdapter : Destroy method 'close' on bean with name 'nacosServiceRegistry' threw an exception: java.lang.NullPointerException 2020-12-08 10:51:24.281 INFO 9163 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' 2020-12-08 10:51:24.462 INFO 9163 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'browserPersistenceUnit' 2020-12-08 10:51:24.469 INFO 9163 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : Browser-HikariPool - Shutdown initiated... 2020-12-08 10:51:24.473 INFO 9163 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : Browser-HikariPool - Shutdown completed. 2020-12-08 10:51:24.473 INFO 9163 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'sopPersistenceUnit' 2020-12-08 10:51:24.474 INFO 9163 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : SOP-HikariPool - Shutdown initiated... 2020-12-08 10:51:24.486 INFO 9163 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : SOP-HikariPool - Shutdown completed.
Acutally behavior
How to Reproduce Steps to reproduce the behavior:
Desktop (please complete the following information):
Additional context Add any other context about the problem here.