snehac-miner / redis

Automatically exported from code.google.com/p/redis
0 stars 0 forks source link

Slave disconnects from proxied Master / keepalive #80

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am connecting a Slave to a Master through a proxy and since the proxy has an 
"inactivity" 
timeout, the slave constantly disconnects and re-connects to the Master.. 
forcing a BGSAVE and 
SYNC.

I noticed there is some code for keepalive: anet.c -> anetTcpKeepAlive() except 
it is not being 
called anywhere.

I've added the following code, but it doesn't seem to work. I'm probably 
missing something...

Are you able to implement this feature in future versions? In the meantime I 
have to set my 
proxy's timeout much higher.

--- redis.c     2009-10-29 23:38:50.000000000 -0400
+++ redis.c.new 2009-10-29 23:39:44.000000000 -0400
@@ -1530,6 +1530,7 @@

     anetNonBlock(NULL,fd);
     anetTcpNoDelay(NULL,fd);
+    anetTcpKeepAlive(NULL,fd);
     if (!c) return NULL;
     selectDb(c,0);
     c->fd = fd;

Thanks!

Original issue reported on code.google.com by youwanta...@gmail.com on 30 Oct 2009 at 3:43

GoogleCodeExporter commented 8 years ago

Original comment by anti...@gmail.com on 31 Oct 2009 at 10:06

GoogleCodeExporter commented 8 years ago
Hello, I think that the only way to play well with such a proxy is to make the 
master 
send a PING from time to time to the slave. I'll fix this. In most case this 
should not 
be needed since even under very low load (few queries every hour) this should 
not 
happen, but I understand there are kind of applications where the writes are 
very 
rare, so it's worth adding.

I think I'll set this option off by default with "pingslave off" in the config 
file, but 
users can turn it on if needed.

Cheers,
Salvatore

Original comment by anti...@gmail.com on 1 Nov 2009 at 8:08

GoogleCodeExporter commented 8 years ago
Hello Salvatore,

I think that is a great idea! I might add a "pingslavedelay 300" which defines 
the interval for sending pings, if 
possible. Most proxies have customizable timeouts, so hardcoded interval might 
not solve this.

If you want I can help to write this feature and send you a patch if this would 
save you some time.

Let me know.

Original comment by youwanta...@gmail.com on 2 Nov 2009 at 1:49

GoogleCodeExporter commented 8 years ago
I am assuming that you use Linux, and if so, just setting the keepalive option 
on the socket may not be enough, 
as the default idle interval before a probe is sent is set to 2 hours. This is 
of course configurable per socket. 

Please see my patch linked from 
http://code.google.com/p/redis/issues/detail?id=224, it adds an option to 
specify the interval in which to start sending probes, the same interval 
between probes, and will also break the 
connection when a probes reveals a broken connection

Original comment by tric...@gmail.com on 6 Apr 2010 at 11:02

GoogleCodeExporter commented 8 years ago
Closing this issue as there is 224 that is duplicated but with a better patch

Original comment by anti...@gmail.com on 23 Aug 2010 at 3:31