soveran / redisent

Sentinels aware Redis client.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List of Redis healthy/hosts becomes very long

scalp42 opened this issue · comments

Testing Redisent, I noticed that after ~30 mins the array for redis.healthy and redis.hosts keep growing:

> redis.healthy.count
=> 54768

> redis.hosts.count
=> 19683

Here is after initializing a fresh Redis + Sentinel setup:

[1] pry(main)>
[2] pry(main)> require 'redisent'
=> true
[3] pry(main)> sentinels = ["192.168.99.100:26391",
[3] pry(main)*   '192.168.99.100:26392',
[3] pry(main)* '192.168.99.100:26393']
=> ["192.168.99.100:26391", "192.168.99.100:26392", "192.168.99.100:26393"]
[4] pry(main)> redis = Redisent.new(hosts: sentinels, name: 'mymaster')
=> #<Redisent:0x007f88692d1ec0
 @auth=nil,
 @client=Redic,
 @healthy=
  ["192.168.99.100:26391",
   "192.168.99.100:26392",
   "192.168.99.100:26393",
   "192.168.99.100:26392",
   "192.168.99.100:26393",
   "192.168.99.100:26391",
   "192.168.99.100:26393",
   "192.168.99.100:26392",
   "192.168.99.100:26391"],
 @hosts=
  ["192.168.99.100:26391",
   "192.168.99.100:26392",
   "192.168.99.100:26393",
   "192.168.99.100:26392",
   "192.168.99.100:26393",
   "192.168.99.100:26391",
   "192.168.99.100:26393",
   "192.168.99.100:26392",
   "192.168.99.100:26391"],
 @invalid=[],
 @name="mymaster",
 @prime=
  #<Redic:0x007f88692d1df8
   @buffer={},
   @client=#<Redic::Client:0x007f88692d1da8 @connection=false, @semaphore=#<Thread::Mutex:0x007f88692d1d80>, @timeout=10000000, @uri=#<URI::Generic redis://172.18.0.2:6379>>,
   @url="redis://172.18.0.2:6379">,
 @scout=
  #<Redic:0x007f88692d1ad8
   @buffer={},
   @client=
    #<Redic::Client:0x007f88692d1a88
     @connection=#<Hiredis::Ext::Connection:0x007f886b137680>,
     @semaphore=#<Thread::Mutex:0x007f88692d1a60>,
     @timeout=10000000,
     @uri=#<URI::Generic redis://192.168.99.100:26391>>,
   @url="redis://192.168.99.100:26391">,
 @unknown=[]>
[5] pry(main)> redis.hosts.count
=> 9
[6] pry(main)> redis.healthy.count
=> 9

Just noticed that when it takes forever to timeout (see: #1):

[13] pry(main)> redis.call('ping')
^CInterrupt:
from /Users/scalp/.rvm/gems/ruby-2.3.1@scraper/gems/redic-1.5.0/lib/redic/connection.rb:11:in `connect'
[14] pry(main)>
[14] pry(main)> redis.healthy.count
=> 27
[15] pry(main)> redis.healthy.count
=> 27
[16] pry(main)> redis.hosts.count
=> 27
[17] pry(main)> redis.healthy.count
=> 27
[18] pry(main)> redis.call('ping')
^CInterrupt:
from /Users/scalp/.rvm/gems/ruby-2.3.1@scraper/gems/redic-1.5.0/lib/redic/connection.rb:11:in `connect'
[19] pry(main)> redis.healthy.count
=> 27
[20] pry(main)> redis.healthy.count
=> 27
[21] pry(main)> redis.call('ping')
^CInterrupt:
from /Users/scalp/.rvm/gems/ruby-2.3.1@scraper/gems/redic-1.5.0/lib/redic/connection.rb:11:in `connect'
[22] pry(main)> redis.healthy.count
=> 81

Letting run for ~30 secs:

[34] pry(main)> redis.call('ping')
^CInterrupt:
from /Users/scalp/.rvm/gems/ruby-2.3.1@scraper/gems/redic-1.5.0/lib/redic/connection.rb:11:in `connect'
[35] pry(main)> puts %|#{redis.healthy.count}:#{redis.hosts.count}|;
243:243

I'm not sure if it's intended or not.

Should be fixed in 0.1.0 (just released!)