Permalink
Browse files

Check for EAGAIN in sendBulkToSlave().

Sometime an osx master with a Linux server over a slow link caused
a strange error where osx called the writable function for
the socket but actually apparently there was no room in the socket
buffer to accept the write: write(2) call returned an EAGAIN error,
that was not checked, so we considered write(2) == 0 always as a connection
reset, which was unfortunate since the bulk transfer has to start again.

Also more errors are logged with the WARNING level in the same code path
now.
  • Loading branch information...
1 parent 04fe000 commit 970de3e9c0f4e4b0ac56d1710e3b66f4a0cd06a5 @antirez committed Feb 5, 2014
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/replication.c
View
@@ -613,9 +613,11 @@ void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) {
return;
}
if ((nwritten = write(fd,buf,buflen)) == -1) {
- redisLog(REDIS_VERBOSE,"Write error sending DB to slave: %s",
- strerror(errno));
- freeClient(slave);
+ if (errno != EAGAIN) {
+ redisLog(REDIS_WARNING,"Write error sending DB to slave: %s",
+ strerror(errno));
+ freeClient(slave);
+ }
return;
}
slave->repldboff += nwritten;
@@ -627,6 +629,7 @@ void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) {
slave->repl_ack_time = server.unixtime;
if (aeCreateFileEvent(server.el, slave->fd, AE_WRITABLE,
sendReplyToClient, slave) == AE_ERR) {
+ redisLog(REDIS_WARNING,"Unable to register writable event for slave bulk transfer: %s", strerror(errno));
freeClient(slave);
return;
}

0 comments on commit 970de3e

Please sign in to comment.