[0.10.0_nightly_d9ed54c-1] Influxdb opening too many TCP connections
Hi,
I am trying to bring up InfluxDB cluster and as soon as one cluster member is up I checked the tcp connections and I see 100+ TCP connections in TIME_WAIT state. The number keeps going up and down (as shown below). I understand that it may be trying to connect to other cluster members but is it really needed to have so many open connections ? And also, these IPv6 ?
[root@host1]# netstat -an | grep 8088 | wc -l
102
[root@host1]# netstat -an | grep 8088 | wc -l
105
[root@host1]# netstat -an | grep 8088 | wc -l
92
[root@host1]# netstat -an | grep 8088 | wc -l
96
[root@host1]# netstat -an | grep 8088 | wc -l
97
[root@host1]# netstat -an | grep 8088 | wc -l
98
[root@host1]# netstat -an | grep 8088 | wc -l
99
[root@host1]# netstat -an | grep 8088 | wc -l
100
..
...
[root@host1]# netstat -an | grep 8088
tcp 0 0 :::8088 :::* LISTEN
tcp 0 0 ::1:8088 ::1:39158 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38895 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39147 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39035 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38924 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39070 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38996 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38882 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38963 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39193 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38894 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39183 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39198 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38928 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39139 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39153 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39101 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39078 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38874 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38941 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39009 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39212 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39122 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38914 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39079 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38947 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39062 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38994 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38901 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39034 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39177 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39181 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38935 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39133 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39040 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39051 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39208 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39109 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38990 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39003 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39028 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39020 TIME_WAIT
tcp 0 0 ::1:8088 ::1:38952 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39142 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39104 TIME_WAIT
tcp 0 0 ::1:8088 ::1:39046 TIME_WAIT
....
....
Thanks, Sarat
A quick update on this .. when I brought up other two members of the cluster, I see TCP connections moved to ESTABLISHED state, but the number of TCP connections is very high (64k in this case !!).
[root@host1]# netstat -an | grep ":8088" | wc -l
65439
From the influxdb logs, I see the following:
[metastore] 2016/01/05 14:59:39 Join node localhost:8088 failed: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsockopp
t: connection refused: retrying...
[metastore] 2016/01/05 14:59:39 Join node 172.31.194.3:8088 failed: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsocc
kopt: connection refused: retrying...
[metastore] 2016/01/05 14:59:39 Join node 172.31.196.113:8088 failed: rpc dial: dial tcp 172.31.196.113:8088: getsockopt: connection ree
fused: retrying...
[metastore] 2016/01/05 14:59:39 fetch metastore: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsockopt: connection ree
fused
[metastore] 2016/01/05 14:59:40 Join node localhost:8088 failed: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsockopp
t: connection refused: retrying...
[metastore] 2016/01/05 14:59:40 Join node 172.31.194.3:8088 failed: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsocc
kopt: connection refused: retrying...
[metastore] 2016/01/05 14:59:40 Join node 172.31.196.113:8088 failed: rpc dial: dial tcp 172.31.196.113:8088: getsockopt: connection ree
fused: retrying...
[metastore] 2016/01/05 14:59:40 fetch metastore: rpc dial: dial tcp 172.31.196.113:8088: getsockopt: connection refused
[metastore] 2016/01/05 14:59:41 Join node localhost:8088 failed: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsockopp
t: connection refused: retrying...
[metastore] 2016/01/05 14:59:41 Join node 172.31.194.3:8088 failed: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsocc
kopt: connection refused: retrying...
[metastore] 2016/01/05 14:59:41 Join node 172.31.196.113:8088 failed: rpc dial: dial tcp 172.31.196.113:8088: getsockopt: connection reefused: retrying...
[metastore] 2016/01/05 14:59:41 fetch metastore: rpc Error failed: dial leader: dial tcp 172.31.196.113:8088: getsockopt: connection reefused
[tcp] 2016/01/05 15:00:24 tcp.Mux: handler not registered: 71
When I run the influx client locally, it is not connecting to the server:
[root@host1]# influx
Failed to connect to http://localhost:8086
Please check your connection settings and ensure 'influxd' is running.
[root@host1]# pgrep influxd
16120
netstat o/p:
...
...
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:56614 ESTABLISHED
tcp 0 0 ::1:8088 ::1:50261 ESTABLISHED
tcp 0 0 ::1:8088 ::1:56208 ESTABLISHED
tcp 0 0 ::1:8088 ::1:43434 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:53228 ESTABLISHED
tcp 0 0 ::1:8088 ::1:43766 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:60033 ESTABLISHED
tcp 0 0 ::1:8088 ::1:51773 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:59106 ESTABLISHED
tcp 0 0 ::1:8088 ::1:54239 ESTABLISHED
tcp 0 0 ::1:8088 ::1:44176 ESTABLISHED
tcp 0 0 ::1:8088 ::1:51979 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:45878 ESTABLISHED
tcp 0 0 ::1:8088 ::1:38775 ESTABLISHED
tcp 0 0 ::1:44348 ::1:8088 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:59359 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:47290 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:60962 ESTABLISHED
tcp 0 0 ::1:8088 ::1:56665 ESTABLISHED
tcp 0 0 ::1:45010 ::1:8088 ESTABLISHED
tcp 0 0 ::1:8088 ::1:58947 ESTABLISHED
tcp 0 0 ::1:8088 ::1:42568 ESTABLISHED
tcp 0 0 ::1:53025 ::1:8088 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:48164 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:52166 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:37506 ESTABLISHED
tcp 0 0 ::1:8088 ::1:35295 ESTABLISHED
tcp 0 0 ::1:49991 ::1:8088 ESTABLISHED
tcp 0 0 ::1:8088 ::1:49220 ESTABLISHED
tcp 0 0 ::1:8088 ::1:51974 ESTABLISHED
tcp 0 0 ::1:56577 ::1:8088 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:51785 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:45503 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.194.3:51926 ESTABLISHED
tcp 0 0 ::1:58425 ::1:8088 ESTABLISHED
tcp 0 0 ::1:40321 ::1:8088 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:33313 ESTABLISHED
tcp 0 0 ::ffff:172.31.194.21:8088 ::ffff:172.31.196.113:60564 ESTABLISHED
...
...
64K connections like this !!!
The way I am trying to bring up the cluster is:
create peers.json file on all three servers with the following entry
server1:
["localhost:8088","server2-ip:8088","server3-ip:8088"]
server2:
["localhost:8088","server1-ip:8088","server3-ip:8088"]
server3:
["localhost:8088","server1-ip:8088","server2-ip:8088"]
After this I do "service influxdb start" on each of the servers. I tried changing hostname in .conf file to actual IP-address instead of "localhost" as well.
Thanks, Sarat
@corylanou @mjdesa any thoughts?
@sarat-k Regarding the number of open connections, what is the retry-rate-limit under [hinted-handoff] in your configuration set to? That setting is the number of bytes per second that will try to be replayed against other members in the cluster. If it's set to 0 (infinity), then I would recommend upping it to 1000000 (MB/s) and see if that helps reduce the number of open connections.
Regarding the errors, your peers.json files are incorrect; they should not include localhost:8088. If possible, I would recommend you use the documentation and create the cluster using the -join parameter, which can be set in the /etc/defaults/influxdb file before starting the service. For example, setting it to:
INFLUXD_OPTS="-hostname influx1 -join influx2:8088,influx3:8088"
Yields the corresponding peers.json:
["influx2:8088","influx3:8088"]
And you can use either DNS hostnames or IP's (as long as they are addressable), so that shouldn't matter. If you use the -join method, then you may need to remove your existing peers.json file while the service is stopped since you've already set it manually.
Hi,
Please see inline ...
On Wed, Jan 6, 2016 at 7:14 AM, Ross McDonald [email protected] wrote:
@sarat-k https://github.com/sarat-k Regarding the number of open connections, what is the retry-rate-limit under [hinted-handoff] in your configuration set to? That setting is the number of bytes per second that will try to be replayed against other members in the cluster. If it's set to 0 (infinity), then I would recommend upping it to 1000000 (MB/s) and see if that helps reduce the number of open connections.
[Sarat] retry-rate-limit is set to 0 (default config). I will change to finite number and try.
Regarding the errors, your peers.json files are incorrect; they should not include localhost:8088. If possible, I would recommend you use the documentation https://docs.influxdata.com/influxdb/v0.9/guides/clustering/ and create the cluster using the -join parameter, which can be set in the /etc/defaults/influxdb file before starting the service. For example, setting it to:
INFLUXD_OPTS="-hostname influx1 -join influx2:8088,influx3:8088"
Yields the corresponding peers.json:
["influx2:8088","influx3:8088"]
[Sarat] I tried this earlier and it works. However, the documented steps require certain sequence to be followed which is fine if we are bringing up these manually. However, most environments are dynamic and these servers machines can come up or go down any time. So, I was trying to see if I can bring up them up same time or any time in any order or at least reduce the number of steps and see if cluster converges or not. This will be easier for scripting etc. With the latest daily, I noticed the following:
- On the 1st node (say server1), I don't set INFLUXD_OPTS to anything and do service influxdb start
- On 2nd, 3rd and 4th nodes I set INFLUXD_OPTS to only server1:8088 and bring them all up around same time. It looks like cluster converged with 1st server as leader, 2 other nodes as followers and 4th one as data.
This simplified the steps a bit. As long as server1 is up, we can add new nodes to cluster. However, when server1 goes down, adding new nodes to cluster won't work in this fashion because we can't continue using server1's IP. Unless we detect this event and pick IP of another raft node (or new leader) and use that to bring up new cluster nodes (as data nodes). I am trying to automate these steps instead of manually bringing up servers (servers can reboot or go thru upgrades and I would like to make them cluster nodes once they are back up automatically).
Another thing I noticed with this daily is, even with two servers cluster is working (at least a leader is elected). Is this expected ? Doesn't raft require odd number of servers ? Can we assume that this behavior will remain same in official releases as well ? It seems like having a converged/functional cluster even with 2 servers is very useful.
Thanks, Sarat
And you can use either DNS hostnames or IP's (as long as they are addressable), so that shouldn't matter. If you use the -join method, then you may need to remove your existing peers.json file while the service is stopped since you've already set it manually.
— Reply to this email directly or view it on GitHub https://github.com/influxdata/influxdb/issues/5277#issuecomment-169350433 .
@sarat-k With regards to the clustering configuration, I definitely understand. I'm not 100% sure that just setting the peers.json file alone will work, but let us know if you continue to have issues when leaving out the localhost:8088 entry.
Regarding your question:
even with two servers cluster is working (at least a leader is elected). Is this expected ? Doesn't raft require odd number of servers ? Can we assume that this behavior will remain same in official releases as well ? It seems like having a converged/functional cluster even with 2 servers is very useful.
You are correct that Raft requires at least 3 nodes in order to form a quorum, which leads me to believe that this is a bug. I have seen 2 node clusters that appear to be healthy for a short period of time, but usually have issues later on. I would highly recommend not running a 2-node cluster for a long period of time, or with mission-critical data. The clustering service is currently undergoing a very large development effort at the moment, so these issues may already be resolved with the next release (0.10.0).
[0.10] I have also same problem, before get timeout. then any write could be done (#5327).
netstat -patn | grep 8086 | wc -l
593
@easyrasta Can you provide a gist of the log output from InfluxDB?
Well it seems a memory problem. I created new vm with more memory it's working. I am suprise than I need to set 16 g (#5685).
Closing this since clustering is no longer supported in the open source version. If this turns out to be due to something else and is still happening in 0.13, please open another issue so we can fix this. Thanks.