gpt4 book ai didi

java - 常规和 Spring 抽象的 Ignite 事务失败,并在手动重新连接后出现 IllegalStateException,并将 clientReconnectDisabled 设置为 true

转载 作者:行者123 更新时间:2023-12-01 19:50:21 25 4
gpt4 key购买 nike

我们正在运行版本 2.4 并使用 Spring IgniteSpringBean , SpringTransactionManager & Spring Data用于集群和事务缓存访问的存储库。

由于我们遇到了很多与 IgniteClientDisconnectedException 相关的问题,因此我正在编写一个手动分段解析器(通过禁用自动客户端重新连接并将 clientReconnectDisabled 设置为 true)来检测这种情况(使用定期运行的简单缓存查询)&通过 IgniteSpringBean#close 发起断开连接然后按照描述重新连接 here

我在缓存访问方面遇到了其他问题,已按照描述解决了 here

但问题是,每当我尝试使用 Spring 事务注释方法时,它都会无法创建事务,并出现 IllegalStateException 提到网格处于无效状态。

我怀疑这又是我之前(上面提到的)过时引用所遇到的相同问题,并且可能需要通过更新 SpringTransactionManager 中的内核引用来在代码中处理它。我正在尝试该修复,如果有效的话将会更新。

同时,如果有人有更简单/更快的修复方法/建议,请分享。

下面是异常(exception)情况,

com.***.dcm.exception.InternalServerErrorException: Error while creating the definition. Message is : Could not create Ignite transaction; nested exception is java.lang.IllegalStateException: Grid is in invalid state to perform this operation. It either not started yet or has already being or have stopped [igniteInstanceName=null, state=STOPPED]
at com.***.dcm.topology.middleware.controller.TopologyServiceControllerHelper.createTopologyDefinition(TopologyServiceControllerHelper.java:124)
at com.***.dcm.topology.middleware.controller.TopologyServiceController.createTopologyDefinition(TopologyServiceController.java:129)
2018-07-24 14:11:00.519 ERROR b731ba99e9b2 --- [nio-7099-exec-1] .d.t.m.c.TopologyServiceControllerHelper : Error while creating the definition. Message is : Could not create Ignite transaction; nested exception is java.lang.IllegalStateException: Grid is in invalid state to perform this operation. It either not started yet or has already being or have stopped [igniteInstanceName=null, state=STOPPED]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

最佳答案

2.5版本修复重连后关闭缓存的问题( https://issues.apache.org/jira/browse/IGNITE-2766 )。

据我了解,您想要创建一个新的 ignite 实例并将其用于 SpringTransactionManager。我认为这不是正确的方法,因为例如 IgniteRepositoryImpl#cache 中也有缓存实例也需要重新初始化。

我确实建议使用 IgniteClientDisconnectedException#reconnectFuture()返回重新连接发生时将完成的 future 的方法。因此,您可以阻止客户端并等待,直到 future 得到解决并且客户端变得活跃。例如:

public void checkAndReconnect(){
try{
// make ignite query
}catch(IgniteClientDisconnectedException ex){
ex.reconnectFuture().get();
}
}

希望它有助于解决连接问题。

关于java - 常规和 Spring 抽象的 Ignite 事务失败,并在手动重新连接后出现 IllegalStateException,并将 clientReconnectDisabled 设置为 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51509902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com