sendFile blocks too long for use with active replication

Former-commit-id: aad6a7ce159a3679633020dc407a2068129bbd49
This commit is contained in:
John Sully 2020-05-29 20:27:45 -04:00
parent e380087cdb
commit 27cae3750c

View File

@ -1386,13 +1386,15 @@ void sendBulkToSlave(connection *conn) {
* fallback to normal read+write otherwise. */ * fallback to normal read+write otherwise. */
nwritten = 0; nwritten = 0;
#if HAVE_SENDFILE #if HAVE_SENDFILE
if (!g_pserver->tls_replication) { if (!g_pserver->tls_replication && !g_pserver->fActiveReplica) { // sendfile blocks too long for active replication
if ((nwritten = redis_sendfile(conn->fd,replica->repldbfd, if ((nwritten = redis_sendfile(conn->fd,replica->repldbfd,
replica->repldboff,PROTO_IOBUF_LEN)) == -1) replica->repldboff,PROTO_IOBUF_LEN)) == -1)
{ {
if (errno != EAGAIN) { if (errno != EAGAIN) {
serverLog(LL_WARNING,"Sendfile error sending DB to replica: %s", serverLog(LL_WARNING,"Sendfile error sending DB to replica: %s",
strerror(errno)); strerror(errno));
ul.unlock();
aeLock.arm(nullptr);
freeClient(replica); freeClient(replica);
} }
return; return;
@ -1408,6 +1410,8 @@ void sendBulkToSlave(connection *conn) {
if (buflen <= 0) { if (buflen <= 0) {
serverLog(LL_WARNING,"Read error sending DB to replica: %s", serverLog(LL_WARNING,"Read error sending DB to replica: %s",
(buflen == 0) ? "premature EOF" : strerror(errno)); (buflen == 0) ? "premature EOF" : strerror(errno));
ul.unlock();
aeLock.arm(nullptr);
freeClient(replica); freeClient(replica);
return; return;
} }
@ -1415,6 +1419,8 @@ void sendBulkToSlave(connection *conn) {
if (connGetState(conn) != CONN_STATE_CONNECTED) { if (connGetState(conn) != CONN_STATE_CONNECTED) {
serverLog(LL_WARNING,"Write error sending DB to replica: %s", serverLog(LL_WARNING,"Write error sending DB to replica: %s",
connGetLastError(conn)); connGetLastError(conn));
ul.unlock();
aeLock.arm(nullptr);
freeClient(replica); freeClient(replica);
} }
return; return;