summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-10-04 12:59:24 +0200
committerantirez <antirez@gmail.com>2013-10-04 13:01:49 +0200
commitd7fa6d9aba0bb765d299171c796aeff754261e08 (patch)
treeb6c2364f898accc87f7f6d8b263c5fc0511e5ecd
parentc8c1006cf4dd01ae8df844ae2c8fe36ca1bff5bc (diff)
downloadredis-d7fa6d9aba0bb765d299171c796aeff754261e08.tar.gz
Replication: fix master timeout.
Since we started sending REPLCONF ACK from slaves to masters, the lastinteraction field of the client structure is always refreshed as soon as there is room in the socket output buffer, so masters in timeout are detected with too much delay (the socket buffer takes a lot of time to be filled by small REPLCONF ACK <number> entries). This commit only counts data received as interactions with a master, solving the issue.
-rw-r--r--src/networking.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c
index ff3d951ff..4233dd306 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -813,7 +813,13 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
return;
}
}
- if (totwritten > 0) c->lastinteraction = server.unixtime;
+ if (totwritten > 0) {
+ /* For clients representing masters we don't count sending data
+ * as an interaction, since we always send REPLCONF ACK commands
+ * that take some time to just fill the socket output buffer.
+ * We just rely on data / pings received for timeout detection. */
+ if (!(c->flags & REDIS_MASTER)) c->lastinteraction = server.unixtime;
+ }
if (c->bufpos == 0 && listLength(c->reply) == 0) {
c->sentlen = 0;
aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);