处理Springboot项目启动时streamBridge.send导致的卡住卡死问题

news2024/11/23 11:31:31

现象

  • 我们的Spring Boot 项目启动时,偶现卡死的现象,启动到一半卡主不动了
2023-01-16 10:23:10.338  INFO 1 --- [  restartedMain] com.hazelcast.core.LifecycleService      : [172.18.0.14]:5701 [dev] [4.2.4] [172.18.0.14]:5701 is STARTED
2023-01-16 10:23:12.391  INFO 1 --- [  restartedMain] c.h.h.HazelcastCacheRegionFactory        : Starting up HazelcastCacheRegionFactory
2023-01-16 10:23:12.396  INFO 1 --- [  restartedMain] c.h.h.i.IHazelcastInstanceFactory        : Using existing HazelcastInstance [unit].
2023-01-16 10:23:16.685  INFO 1 --- [ntLoopGroup-2-1] com.newatc.socketio.SocketIOServer       : SocketIO server started at port: 7654
2023-01-16 10:23:16.702  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : controllerAgentServer bean listeners added
2023-01-16 10:23:16.972  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : channelParamHandler bean listeners added
2023-01-16 10:23:16.979  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : controllerAlarmHandler bean listeners added
2023-01-16 10:23:16.988  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : controllerFaultHandler bean listeners added
2023-01-16 10:23:16.995  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : controllerModelHandler bean listeners added
2023-01-16 10:23:17.000  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : controllerTimeHandler bean listeners added
2023-01-16 10:23:17.006  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : dayPlanParamHandler bean listeners added
2023-01-16 10:23:17.011  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : detectorEventHandler bean listeners added
2023-01-16 10:23:17.016  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : detectorParamHandler bean listeners added
2023-01-16 10:23:17.022  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : lampOffHandler bean listeners added
2023-01-16 10:23:17.027  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : patternParamHandler bean listeners added
2023-01-16 10:23:17.033  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : phaseFlowHandler bean listeners added
2023-01-16 10:23:17.038  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : phaseParamHandler bean listeners added
2023-01-16 10:23:17.044  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : phaseStatusHandler bean listeners added
2023-01-16 10:23:17.050  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : scheduleParamHandler bean listeners added
2023-01-16 10:23:17.057  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : signalIPParamHandler bean listeners added
2023-01-16 10:23:17.062  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : softwareVersionHandler bean listeners added
2023-01-16 10:23:17.068  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : stageParamHandler bean listeners added
2023-01-16 10:23:17.073  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : trafficParamsHandler bean listeners added
2023-01-16 10:23:17.079  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : vehGPSTrajectoryHandler bean listeners added
2023-01-16 10:23:17.084  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : wirelessOpLogHandler bean listeners added
2023-01-16 10:23:17.091  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : wirelessSecurityHandler bean listeners added
2023-01-16 10:23:18.018  INFO 1 --- [ntLoopGroup-3-1] c.n.socketio.handler.AuthorizeHandler    : channel active cb27f0b9-236a-404c-8cb1-369366729ce2
2023-01-16 10:23:18.466  INFO 1 --- [ntLoopGroup-3-1] c.h.i.p.impl.PartitionStateManager       : [172.18.0.14]:5701 [dev] [4.2.4] Initializing cluster partition table arrangement...
2023-01-16 10:23:18.776  INFO 1 --- [ntLoopGroup-3-1] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.101 Port=38167 unitId:101
2023-01-16 10:23:18.981  INFO 1 --- [ntLoopGroup-3-2] c.n.socketio.handler.AuthorizeHandler    : channel active 539fb94d-a5de-4fef-b81d-82803885973f
2023-01-16 10:23:19.008  INFO 1 --- [ntLoopGroup-3-2] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.93 Port=39568 unitId:93
2023-01-16 10:23:22.177  INFO 1 --- [        Timer-0] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.101
2023-01-16 10:23:22.244  INFO 1 --- [        Timer-2] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.93
2023-01-16 10:23:25.953  INFO 1 --- [ntLoopGroup-3-3] c.n.socketio.handler.AuthorizeHandler    : channel active 874e3919-489d-4970-8a53-e51e8a880057
2023-01-16 10:23:25.978  INFO 1 --- [ntLoopGroup-3-3] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.107 Port=45166 unitId:107
2023-01-16 10:23:26.821  WARN 1 --- [  restartedMain] onConfiguration$FunctionBindingRegistrar : You have defined function definition that does not exist: streamBridge
2023-01-16 10:23:29.213  INFO 1 --- [        Timer-4] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.107
2023-01-16 10:24:00.174  INFO 1 --- [        Timer-1] c.n.unit.agent.ControllerAgentServer     : Get signal time ipAddress:172.16.1.101
2023-01-16 10:24:00.248  INFO 1 --- [        Timer-3] c.n.unit.agent.ControllerAgentServer     : Get signal time ipAddress:172.16.1.93
2023-01-16 10:24:07.212  INFO 1 --- [        Timer-5] c.n.unit.agent.ControllerAgentServer     : Get signal time ipAddress:172.16.1.107
2023-01-16 10:24:37.351  INFO 1 --- [ntLoopGroup-3-4] c.n.socketio.handler.AuthorizeHandler    : channel active bd580b9b-8050-4315-bf0d-07e8acc797b2
2023-01-16 10:24:37.368  INFO 1 --- [ntLoopGroup-3-4] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.107 Port=45167 unitId:107
2023-01-16 10:24:40.595  INFO 1 --- [        Timer-6] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.107
2023-01-16 10:24:43.373  INFO 1 --- [ntLoopGroup-3-5] c.n.socketio.handler.AuthorizeHandler    : channel active a7ffe375-462d-4c18-bd67-1811933b8084
2023-01-16 10:24:43.388  INFO 1 --- [ntLoopGroup-3-5] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.93 Port=39570 unitId:93
2023-01-16 10:24:46.611  INFO 1 --- [        Timer-8] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.93
2023-01-16 10:25:18.595  INFO 1 --- [        Timer-7] c.n.unit.agent.ControllerAgentServer     : Get signal time ipAddress:172.16.1.107
2023-01-16 10:25:24.612  INFO 1 --- [        Timer-9] c.n.unit.agent.ControllerAgentServer     : Get signal time ipAddress:172.16.1.93
2023-01-16 10:25:51.726  INFO 1 --- [ntLoopGroup-3-6] c.n.socketio.handler.AuthorizeHandler    : channel active fb525bf4-fdd7-4f88-9a0d-88c923ef24df
2023-01-16 10:25:51.743  INFO 1 --- [ntLoopGroup-3-6] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.107 Port=45168 unitId:107
2023-01-16 10:25:54.964  INFO 1 --- [       Timer-10] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.107
2023-01-16 10:26:32.965  INFO 1 --- [       Timer-11] c.n.unit.agent.ControllerAgentServer     : Get signal time ipAddress:172.16.1.107
  • 启动卡死不是必现,综合了出现卡死时的情况,发现,当出现kafka发送消息时,偶尔会卡主。这让我想起之前处理的一个启动报错 Spring Cloud Stream kafka项目启动时报错
  • 项目使用的是spring-cloud-starter-stream-kafka,函数式编程。代码业务逻辑是,程序接收到硬件的socket.io消息推送,就会使用kafka转发消息
  • 之前报错原因是项目启动时,在还未与kafka建立连接时,程序就接收到socket消息开始按照程序逻辑发送kafka消息,导致空指针异常,之后加了判断与初始化处理,问题解决
  • 本次现象类似,但初始化部署,程序没有连接硬件时,启动都是成功的。但程序已经使用一段时间,连接上硬件,接收硬件上报数据,就出现了偶发的更新启动卡死现象

排查和解决

  • 先是对比了启动失败和启动成功的日志,没有发现什么异常报错,启动成功日志如下
2023-01-16 10:13:32.705  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : vehGPSTrajectoryHandler bean listeners added
2023-01-16 10:13:32.709  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : wirelessOpLogHandler bean listeners added
2023-01-16 10:13:32.715  INFO 1 --- [  restartedMain] c.n.s.a.SpringAnnotationScanner          : wirelessSecurityHandler bean listeners added
2023-01-16 10:13:33.786  INFO 1 --- [ntLoopGroup-3-1] c.n.socketio.handler.AuthorizeHandler    : channel active 65c277be-ed56-496a-9a3f-7243b1e7adff
2023-01-16 10:13:33.786  INFO 1 --- [ntLoopGroup-3-2] c.n.socketio.handler.AuthorizeHandler    : channel active f9f1acf4-ada2-4590-b949-46e0214e879b
2023-01-16 10:13:34.263  INFO 1 --- [ntLoopGroup-3-1] c.h.i.p.impl.PartitionStateManager       : [172.18.0.14]:5701 [dev] [4.2.4] Initializing cluster partition table arrangement...
2023-01-16 10:13:34.583  INFO 1 --- [ntLoopGroup-3-1] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.93 Port=39558 unitId:93
2023-01-16 10:13:34.583  INFO 1 --- [ntLoopGroup-3-2] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.107 Port=45152 unitId:107
2023-01-16 10:13:37.960  INFO 1 --- [        Timer-0] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.93
2023-01-16 10:13:37.960  INFO 1 --- [        Timer-1] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.107
2023-01-16 10:13:38.637  INFO 1 --- [ntLoopGroup-3-3] c.n.socketio.handler.AuthorizeHandler    : channel active 6dce6405-53af-4914-aa6c-dcbf2860babc
2023-01-16 10:13:38.660  INFO 1 --- [ntLoopGroup-3-3] c.n.unit.agent.ControllerAgentServer     : onConnect -- client = 172.16.1.101 Port=38154 unitId:101
2023-01-16 10:13:41.930  INFO 1 --- [        Timer-4] c.n.unit.agent.ControllerAgentServer     : Sync signal time ipAddress:172.16.1.101
2023-01-16 10:13:42.544  WARN 1 --- [  restartedMain] onConfiguration$FunctionBindingRegistrar : You have defined function definition that does not exist: streamBridge
2023-01-16 10:13:43.942  INFO 1 --- [ntLoopGroup-3-1] c.n.socketio.protocol.PacketDecoder      : Rcv Signal Machine IP:172.16.1.93
2023-01-16 10:13:43.942  INFO 1 --- [ntLoopGroup-3-2] c.n.socketio.protocol.PacketDecoder      : Rcv Signal Machine IP:172.16.1.107
2023-01-16 10:13:43.942  INFO 1 --- [ntLoopGroup-3-3] c.n.socketio.protocol.PacketDecoder      : Rcv Signal Machine IP:172.16.1.101
2023-01-16 10:13:43.944  INFO 1 --- [ntLoopGroup-3-3] c.n.u.a.handler.SignalIPParamHandler     : rcv:172.16.1.101
2023-01-16 10:13:43.945  INFO 1 --- [ntLoopGroup-3-2] c.n.u.a.handler.SignalIPParamHandler     : rcv:172.16.1.107
2023-01-16 10:13:43.945  INFO 1 --- [ntLoopGroup-3-1] c.n.u.a.handler.SignalIPParamHandler     : rcv:172.16.1.93
2023-01-16 10:13:47.039  INFO 1 --- [  restartedMain] org.jboss.threads                        : JBoss Threads version 3.1.0.Final
2023-01-16 10:13:47.304  INFO 1 --- [  restartedMain] com.newatc.unit.UnitApp                  : Started UnitApp in 41.426 seconds (JVM running for 44.067)
2023-01-16 10:13:47.319  INFO 1 --- [  restartedMain] com.newatc.unit.UnitApp                  : 
----------------------------------------------------------
	Application 'unit' is running! Access URLs:
	Local: 		http://localhost:8282/
	External: 	http://172.18.0.14:8282/
	当前版本为: 		1.4.2
	代码打包时间为: 		202301060900
	Profile(s): 	[prod, api-docs, no-liquibase]
----------------------------------------------------------
2023-01-16 10:13:47.320  INFO 1 --- [  restartedMain] com.newatc.unit.UnitApp                  : 
----------------------------------------------------------
	Config Server: 	Connected to Consul Server running in Docker
----------------------------------------------------------
  • 这个启动卡死现象是偶发的,确定与kafka发送消息有关,但不是必现,无法通过错误日志和日志对比找问题,只好另寻他法
  • 由于启动成功的日志里,也有接收硬件消息的日志打印,想着是不是有线程等待,暂时卡主了,需要使用一些自带的java命令来检查下
  • 在docker里使用 jstack 1,结果提示bash: jstack: command not found,去java文件夹看了下,确实没这些命令
    在这里插入图片描述
  • 为了减少镜像包大小,我们使用的是jre版本的java 11 环境docker镜像eclipse-temurin:11-jre-focal(程序镜像包170M左右),没有自带一些java命令,只好换成jdk版本的eclipse-temurin:11-jdk-focal重新打镜像包(300M左右)部署
  • 部署后重现了启动卡死的问题,使用 jstack 1命令查看此时的线程情况,一下子发现了问题Found 1 deadlock.,发现了一个死锁线程,具体日志如下(省略了部分日志):
I have no name!@315764d2cd4b:/$ jstack 1
2023-01-16 11:39:57
Full thread dump OpenJDK 64-Bit Server VM (11.0.17+8 mixed mode, sharing):


JNI global refs: 29, weak refs: 0


Found one Java-level deadlock:
=============================
"restartedMain":
  waiting to lock monitor 0x00007f730406bb00 (object 0x00000000e34c2160, a org.springframework.cloud.stream.binder.DefaultBinderFactory),
  which is held by "nioEventLoopGroup-3-2"
"nioEventLoopGroup-3-2":
  waiting to lock monitor 0x00007f725c019500 (object 0x00000000e1516e80, a java.util.concurrent.ConcurrentHashMap),
  which is held by "restartedMain"

Java stack information for the threads listed above:
===================================================
"restartedMain":
	at org.springframework.cloud.stream.binder.DefaultBinderFactory.getBinder(DefaultBinderFactory.java:129)
	- waiting to lock <0x00000000e34c2160> (a org.springframework.cloud.stream.binder.DefaultBinderFactory)
	at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder.determineTargetProtocol(FunctionConfiguration.java:640)
	at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder.createFunctionHandler(FunctionConfiguration.java:579)
	at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder.bindFunctionToDestinations(FunctionConfiguration.java:562)
	at org.springframework.cloud.stream.function.FunctionConfiguration$FunctionToDestinationBinder.afterPropertiesSet(FunctionConfiguration.java:421)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$287/0x00000008401f6040.getObject(Unknown Source)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	- locked <0x00000000e1516e80> (a java.util.concurrent.ConcurrentHashMap)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	- locked <0x00000000e10d9e48> (a java.lang.Object)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at com.newatc.unit.UnitApp.main(UnitApp.java:72)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11.0.17/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.17/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.17/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@11.0.17/Method.java:566)
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
"nioEventLoopGroup-3-2":
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:216)
	- waiting to lock <0x00000000e1516e80> (a java.util.concurrent.ConcurrentHashMap)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
	at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:264)
	at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:221)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:427)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
	- locked <0x00000000e3d686a0> (a java.lang.Object)
	at org.springframework.cloud.stream.binder.DefaultBinderFactory.initializeBinderContextSimple(DefaultBinderFactory.java:471)
	at org.springframework.cloud.stream.binder.DefaultBinderFactory.getBinderInstance(DefaultBinderFactory.java:265)
	at org.springframework.cloud.stream.binder.DefaultBinderFactory.doGetBinder(DefaultBinderFactory.java:223)
	at org.springframework.cloud.stream.binder.DefaultBinderFactory.getBinder(DefaultBinderFactory.java:151)
	- locked <0x00000000e34c2160> (a org.springframework.cloud.stream.binder.DefaultBinderFactory)
	at org.springframework.cloud.stream.binding.BindingService.getBinder(BindingService.java:389)
	at org.springframework.cloud.stream.binding.BindingService.bindProducer(BindingService.java:273)
	at org.springframework.cloud.stream.function.StreamBridge.resolveDestination(StreamBridge.java:282)
	- locked <0x00000000e3453128> (a org.springframework.cloud.stream.function.StreamBridge)
	at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:210)
	at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:164)
	at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:144)
	at com.newatc.unit.agent.ControllerAgentServer.onConnect(ControllerAgentServer.java:184)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@11.0.17/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@11.0.17/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@11.0.17/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@11.0.17/Method.java:566)
	at com.newatc.socketio.annotation.OnConnectScanner$1.onConnect(OnConnectScanner.java:41)
	at com.newatc.socketio.namespace.Namespace.onConnect(Namespace.java:186)
	at com.newatc.socketio.handler.AuthorizeHandler.connect(AuthorizeHandler.java:151)
	at com.newatc.socketio.handler.AuthorizeHandler.channelActive(AuthorizeHandler.java:90)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:230)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:216)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelActive(AbstractChannelHandlerContext.java:209)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelActive(DefaultChannelPipeline.java:1398)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:230)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:216)
	at io.netty.channel.DefaultChannelPipeline.fireChannelActive(DefaultChannelPipeline.java:895)
	at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:522)
	at io.netty.channel.AbstractChannel$AbstractUnsafe.access$200(AbstractChannel.java:429)
	at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:486)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(java.base@11.0.17/Thread.java:829)

Found 1 deadlock.
  • 看了stack日志,看到了死锁互相等待的线程,就是这个问题了。具体触发死锁的代码为at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:210),还是kafka问题
  • 发现问题,想着等启动完成后,再去执行发送kafka消息的逻辑。再启动类里增加一个公共变量,启动前为false,启动完成后为true,在kafka发送时,使用此变量判断

// 启动类UnitApp
	/**
     * 是否启动完成,默认false,启动完成后置true
     */
    public static Boolean START_COMPLETED = false;
    
	public static void main(String[] args) {
        SpringApplication app = new SpringApplication(UnitApp.class);
        DefaultProfileUtil.addDefaultProfile(app);
        Environment env = app.run(args).getEnvironment();
        logApplicationStartup(env);
        START_COMPLETED = true;
    }

// 使用时
			try {
                if (streamBridge != null && UnitApp.START_COMPLETED) {
                    streamBridge.afterSingletonsInstantiated();
                    streamBridge.send(OUTPUT_BINDING_NAME, mapper.writeValueAsString(offlineEventDTO));
                } else {
                    log.error("streamBridge is null or UnitApp.START_COMPLETED is {}--------!", UnitApp.START_COMPLETED);
                }
            } catch (JsonProcessingException e) {
                log.error(e.getMessage());
            }
  • 问题解决

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/169957.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Unity脚本 --- 常用API(常用类) --- Component类和Transform类

上面这个是Unity核心类图 第一部分 --- Component类 提供了查找组件的方法&#xff08;当前物体的&#xff0c;子物体&#xff0c;父物体的&#xff09; 1.颜色&#xff08;color&#xff09;是材质&#xff08;meterial&#xff09;控制的&#xff0c;meterial&#xff08…

【FreeRTOS】在Cortex-M4开发板上移植FreeRTOS并且实现LED灯闪烁(保姆级教程)

相信有不少小伙伴手上只有M4的开发板&#xff0c;想要移植FreeRTOS&#xff1b;但是&#xff0c;网上大部分都是M3移植教程。因此&#xff0c;陷入深深的迷茫中&#xff0c;难不成只能使用仿真了&#xff1f;&#xff1f;&#xff1f;&#x1f914;因此&#xff0c;小编特意写了…

【Linux】静态库和动态库

Linux为什么不允许普通用户给目录建立硬链接呢&#xff1f; 系统层面上有.和…硬链接指向目录。假设我们是超级用户&#xff0c;允许给目录建立硬链接&#xff0c;给根目录建立硬链接&#xff0c;从根目录开始查找&#xff0c;当查找硬链接的时候就是根目录&#xff0c;这时候递…

面试官让我聊聊 MQ 的数据丢失问题,没想到水这么深。。。

目录 一、背景引入二、Kafka分布式存储架构三、Kafka高可用架构四、画图复现Kafka的写入数据丢失问题五、Kafka的ISR机制是什么&#xff1f;六、Kafka写入的数据如何保证不丢失&#xff1f;七、总结 一、背景引入 这篇文章&#xff0c;给大家聊一下写入Kafka的数据该如何保证…

Git常用命令(全局设置获取仓库)

新建仓库: 填写名称等信息&#xff0c;根据需要选择私有&#xff0c;开源等选项。 创建完成。 邀请成员&#xff1a; Git常用命令 Git全局设置 首先要做的是设置用户名和email地址。这是非常重要的&#xff0c;每次Git提交都会使用该用户信息。 设置用户信息&#xff1a; …

岁末年初捷报频传 HashData斩获多项行业殊荣

凯歌高奏辞旧岁&#xff0c;数据赋智谱新篇。 刚刚过去的2022年&#xff0c;面对充满变数的外部环境&#xff0c;HashData始终坚持以技术为本&#xff0c;持续全面创新&#xff0c;适应数字经济发展趋势&#xff0c;笃行致远&#xff0c;砥砺前行&#xff0c;积极推动企业“上…

VPS融合怪测评脚本(主体已完善,历史遗留问题解决时间未知)(VPS fusion monster evaluation script)

ecs 原仓库链接&#xff1a;https://github.com/spiritLHLS/ecs 支持系统&#xff1a;Ubuntu 18&#xff0c;Debian 8&#xff0c;centos 7&#xff0c;Fedora&#xff0c;Almalinux 8.5, Arch 融合怪测评脚本 bash <(wget -qO- --no-check-certificate https://gitlab.…

Sealer 0.9 :帮助集群和分布式应用实现 Build、 Share、Run

作者&#xff1a;sealer 社区 新春之际&#xff0c;很高兴在此时宣布 Sealer [ 1] 0.9 版本的正式发布。Sealer 是一款致力于探索面向分布式应用的快速打包、交付和运行的解决方案。2021 年5月 Sealer 项目正式开源&#xff1b;短短一年时间&#xff0c;Sealer 在 2022 年 4 月…

人工智能图像识别四大算子

文章目录背景引入图像识别发展简介边缘检测算法*Prewitt算子**Sobel算子**Laplace算子**Conny算子** 文末寄语*背景引入 图像识别是当今计算机科学最热门的研究方向之一。随着科学技术的发展和人类社会的不断进步&#xff0c;图像识别技术在很多行业得到了广泛的应用。本章除了…

【单链表】数据结构,详解单链表,java实现代码

前言&#xff1a; 大家好&#xff0c;我是良辰丫&#x1f353;&#x1f353;&#x1f353;&#xff0c;今天我和大家一起了解一下数据结构中的链表&#xff0c;链表&#xff0c;顾名思义是用链子把一个个数据串连起了的&#xff0c;那么链表和顺序表又有什么不同呢&#xff1f;…

mysql存储过程基本语法

本文来说下mysql存储过程基本语法 文章目录基本语法使用实例变量的使用变量定义declare语句变量赋值用户变量存储过程的参数in 输入参数out 输出参数inout输入输出参数本文小结基本语法 存储过程就是具有名字的一段代码&#xff0c;用来完成一个特定的功能。创建的存储过程保存…

2022年全球白帽常用工具排行榜TOP 10

虽然此时还未到2022年年底&#xff0c;但并不妨碍我们整理一份2022年全球白帽常用的工具榜单&#xff0c;希望能给白帽们和企业安全人员们带来一定的借鉴和参考。 一方面&#xff0c;工具的重要性不言而喻&#xff0c;各大SRC的白帽们也有深刻的切身体会。一个好用且靠谱的工具…

带模糊加工时间的柔性作业车间调度理论和GA复现(python)

文章目录1.模糊作业车间1.1 模糊数1.2 三角模糊数操作1.3 模糊甘特图2.FJSP模糊加工时间GA2.1 GA算法设置2.2 python代码2.3 测试结果1.模糊作业车间 1.1 模糊数 论域X上的模糊集合A由隶属度函数u(x)表示&#xff0c;u(x)取值[0,1]。如果A为三角模糊数&#xff0c;A可以表示为…

软件测试复习07:软件测试过程

作者&#xff1a;非妃是公主 专栏&#xff1a;《软件测试》 个性签&#xff1a;顺境不惰&#xff0c;逆境不馁&#xff0c;以心制境&#xff0c;万事可成。——曾国藩 文章目录测试计划测试设计测试执行测试监控测试结束软件测试过程主要有5个阶段&#xff1a;测试计划、测试设…

《深入浅出计算机组成原理》学习笔记 Day3

ELF和静态链接1. 程序执行&#xff1a;编译、链接和装载2. ELF 格式和链接3. 总结延伸参考1. 程序执行&#xff1a;编译、链接和装载 有这么两个C文件&#xff1a; \\ add.c int add(int a, int b) {return a b; }\\ test.c #include <stdio.h> int main() {int a 1;…

JVM学习(三):聊聊内存泄漏(memory leak)

一、什么是内存泄漏&#xff08;memory leak&#xff09;可达性分析算法来判断对象是否是不再使用的对象&#xff0c;本质都是判断一个对象是否还被引用。那么对于这种情况下&#xff0c;由于代码的实现不同就会出现很多种内存泄漏问题&#xff08;让JVM误以为此对象还在引用中…

最新光速配置VScode运行C/C++教程(W11适用)

文章目录1.下载MingW编译器&#xff1a;2.解压7z压缩文件方法3.VScode配置4.下面看看成果&#xff1a;1.下载MingW编译器&#xff1a; 下载地址 往下面拖找到上面这个东西-下载最新版本 2.解压7z压缩文件方法 7z解压程序官网 下它&#xff01;相信这个时候在装的一般都是6…

【ubuntu | cuda】ubuntu22.04 安装cuda11.3方法

every blog every motto: You can do more than you think. 0. 前言 ubuntu22.04 安装cuda11.3方法记录 1. 正文 1.1 方法一&#xff1a; https://developer.nvidia.com/cuda-11.3.0-download-archive?target_osLinux&target_archx86_64&DistributionUbuntu&…

服务网格领域的百花齐放,是否存在一个更优解?

作者lingsamuel&#xff0c;API7.ai 云原生技术专家&#xff0c;Apache APISIX Committer。 作者林志煌&#xff0c;API7.ai 技术工程师&#xff0c;Apache APISIX contributor。 服务网格是一种技术架构&#xff0c;它用于管理微服务系统中各个服务之间的通信&#xff0c;旨在…

关于volatile和gcc 优化的的思考

volatile是一个特征修饰符&#xff08;type specifier&#xff09; volatile的作用是作为指令关键字&#xff0c;确保本条指令不会因编译器的优化而省略&#xff0c;且要求每次直接读值。这是百度百科的介绍&#xff0c;那编译器是具体是怎么优化的呢。我们知道gcc 是有O0 O1 O…