You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Spring cloud config client config server discovery creates a lot (hundreds) of connections to zookeeper.
We are using spring config server discovery via zookeeper. After migrating to spring 6 and cloud 2022.0.x config server discovery started to create a lot of zookeeper connections (and keeping them alive).
Number of connections depend on number of services already registered in zk. And each time new service gets registered or dissapears from zk, new curator event gets published and another connection / curator instance is getting created.
Zookeeper servers are starting to reject connections due to max client connections limit, while application is trying to dos it with connection retry attempts constantly:
2023-09-08 09:45:46,161 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Opening socket connection to server /10.195.0.22:2181.
2023-09-08 09:45:46,161 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Opening socket connection to server /10.195.0.22:2181.
2023-09-08 09:45:46,161 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Socket connection established, initiating session, client: /10.195.0.22:51638, server: /10.195.0.22:2181
2023-09-08 09:45:46,162 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Socket connection established, initiating session, client: /10.195.0.22:51640, server: /10.195.0.22:2181
2023-09-08 09:45:46,162 WARN lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Session 0x0 for sever /10.195.0.22:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
org.apache.zookeeper.ClientCnxn$EndOfStreamException: Unable to read additional data from server sessionid 0x0, likely server has closed socket
at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:75)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:348)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1262)
2023-09-08 09:45:46,162 WARN lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Session 0x0 for sever /10.195.0.22:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
2023-09-08 09:45:46,174 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Opening socket connection to server /10.195.0.22:2181.
2023-09-08 09:45:46,174 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Socket connection established, initiating session, client: /10.195.0.22:51672, server: /10.195.0.22:2181
2023-09-08 09:45:46,175 WARN lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Session 0x0 for sever /10.195.0.22:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
2023-09-08 09:45:46,250 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Opening socket connection to server /10.195.0.22:2181.
2023-09-08 09:45:46,251 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Socket connection established, initiating session, client: /10.195.0.22:51748, server: /10.195.0.22:2181
2023-09-08 09:45:46,251 WARN lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Session 0x0 for sever /10.195.0.22:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
2023-09-08 09:45:46,336 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Opening socket connection to server /10.195.0.22:2181.
2023-09-08 09:45:46,336 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Socket connection established, initiating session, client: /10.195.0.22:51832, server: /10.195.0.22:2181
2023-09-08 09:45:46,337 WARN lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Session 0x0 for sever /10.195.0.22:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
2023-09-08 09:45:46,378 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Opening socket connection to server /10.195.0.22:2181.
2023-09-08 09:45:46,379 INFO lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Socket connection established, initiating session, client: /10.195.0.22:51882, server: /10.195.0.22:2181
2023-09-08 09:45:46,379 WARN lientCnxn$SendThread [Curator-TreeCache-0-SendThread(10.195.0.22:2181)] Session 0x0 for sever /10.195.0.22:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
...
This gets called right after appplication start and creates (in my case, since zk has some stuff already registered) ~30 connections:
➜ netstat -alpn | grep 2181
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 10.192.1.13:49572 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34700 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34498 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34678 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34582 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34608 10.195.0.22:2181 ESTABLISHED 613337/java
...snipo...
tcp6 0 0 10.192.1.13:34568 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34502 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34666 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34690 10.195.0.22:2181 ESTABLISHED 613337/java
tcp6 0 0 10.192.1.13:34486 10.195.0.22:2181 ESTABLISHED 613337/java
number of connections initially created depends on services already registered in zk. But new connections are creted each time some service registers or unregisters.
The text was updated successfully, but these errors were encountered:
Describe the bug
Spring cloud config client config server discovery creates a lot (hundreds) of connections to zookeeper.
We are using spring config server discovery via zookeeper. After migrating to spring 6 and cloud 2022.0.x config server discovery started to create a lot of zookeeper connections (and keeping them alive).
Number of connections depend on number of services already registered in zk. And each time new service gets registered or dissapears from zk, new curator event gets published and another connection / curator instance is getting created.
Zookeeper servers are starting to reject connections due to max client connections limit, while application is trying to dos it with connection retry attempts constantly:
This gets called right after appplication start and creates (in my case, since zk has some stuff already registered) ~30 connections:
Multiple threads are kept alive
Full stack of what happens when new service gets registered in zk
Sample
Simple example to replicate this
https://github.com/geekonek/spring-cloud-zookeeper-config-server-discovery-dos-example
number of connections initially created depends on services already registered in zk. But new connections are creted each time some service registers or unregisters.
The text was updated successfully, but these errors were encountered: