redis-operator icon indicating copy to clipboard operation
redis-operator copied to clipboard

Close redis client connections

Open devkmsg opened this issue 2 years ago • 0 comments

I noticed that there is a goroutine leak due to opening redis client connections and never closing or reusing them. The goroutine count with a single cluster was increasing by about 2 per reconcile. The following shows the before/after count of redis connection goroutines.

This will ensure the redis client connections get closed which fixes the goroutine leak.

Before
$ while true                                                                                                                                                                                                                                                                                                                                 
do
curl -s http://localhost:8082/debug/pprof/goroutine\?debug\=2 | grep -c -E "go-redis.*NewConnPool"
sleep 60
done
2
2
4
4
6
6
8
8
10
10
12
12
14
14
16
16
18
18
20
20
22
22
24
24
26
26
28
28
30
30
After
$ while true                                                                                                                                                                                                                                                                                                                                 
do
curl -s http://localhost:8082/debug/pprof/goroutine\?debug\=2 | grep -c -E "go-redis.*NewConnPool"
sleep 60
done
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0

devkmsg avatar Sep 15 '22 20:09 devkmsg