简体   繁体   English

Spring 数据 Neo4J - 无法在配置的最长时间内从池中获取连接

[英]Spring Data Neo4J - Unable to acquire connection from pool within configured maximum time

We have a Reactive REST API using Spring Data Neo4j (SpringBoot v2.7.5) deployed to Kube.netes.我们有一个 Reactive REST API 使用 Spring Data Neo4j (SpringBoot v2.7.5) 部署到 Kube.netes。 When running a stress test to determine the breaking point, once the volume of requests that the service can handle has been breached, the service does not auto-recover, even after the load has dropped to a level at which the service can handle.当运行压力测试以确定断点时,一旦服务可以处理的请求量被突破,服务不会自动恢复,即使负载已经下降到服务可以处理的水平。

After the service has fallen over the Neo4J health indicator shows: “org.neo4j.driver.exceptions.ClientException: Unable to acquire connection from the pool within configured maximum time of 60000ms”服务失败后,Neo4J 健康指标显示:“org.neo4j.driver.exceptions.ClientException:无法在配置的最长时间 60000 毫秒内从池中获取连接”

With respect to connection/configuration settings we are using defaults configured by SDN.关于连接/配置设置,我们使用 SDN 配置的默认设置。

Observations: Up until the point at which the service breaks only a small number of connections are utilised, at the point at which it breaks the connections in use jumps up to the max pool size and the above mentioned error is observed.观察:直到服务中断时,仅使用少量连接,在服务中断时,正在使用的连接跳到最大池大小,并观察到上述错误。 No matter how much time passes (even well beyond the max connection lifetime) the service is unable to acquire a connection from the pool.无论经过多少时间(甚至远远超过最大连接生命周期),服务都无法从池中获取连接。 Upon manually shutting down and restarting the service/pod the service returns to a healthy state.手动关闭并重新启动服务/pod 后,服务会恢复到正常状态 state。

As an interim solution we now check the Neo4J health indicator, if the mentioned error is present the liveness state is set to down which triggers Kube.netes to restart the service automatically.作为一个临时解决方案,我们现在检查 Neo4J 健康指标,如果存在上述错误,则 liveness state 将设置为关闭,这会触发 Kube.netes 自动重启服务。 However, I'm wondering if there is an underlying issue with the connections in the pool not getting 'cleaned up'?但是,我想知道池中的连接是否存在未“清理”的潜在问题?

You can take a look at this discussion https://github.com/spring-projects/spring-data-neo4j/issues/2632你可以看看这个讨论https://github.com/spring-projects/spring-data-neo4j/issues/2632

I had the same issue.我遇到过同样的问题。 The problem is that either Spring Framework or Neo4j reactive transaction manager doesn't close connections in a complex reactive flow eg when there are a lot of inner calls/mappings and somewhere inside an exception is thrown.问题是 Spring Framework 或 Neo4j 反应式事务管理器不会关闭复杂反应流中的连接,例如,当有很多内部调用/映射并且内部某处抛出异常时。

So as a workaround you can add @Transactional in such places to avoid multiple transactions to be created.因此,作为一种解决方法,您可以在这些地方添加 @Transactional 以避免创建多个事务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM