From cb310ae6b525d38e8584c522bf538cf056875603 Mon Sep 17 00:00:00 2001 From: wangyuan21 Date: Fri, 22 Apr 2022 16:22:28 +0800 Subject: [PATCH 1/2] Stop sending files if failed in full synchronization --- src/redis_cmd.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/redis_cmd.cc b/src/redis_cmd.cc index 493852d0da3..5509967fb4a 100644 --- a/src/redis_cmd.cc +++ b/src/redis_cmd.cc @@ -4274,10 +4274,12 @@ class CommandFetchFile : public Commander { Util::SockSendFile(repl_fd, fd, file_size).IsOK()) { LOG(INFO) << "[replication] Succeed sending file " << file << " to " << ip; - } else { - LOG(WARNING) << "[replication] Fail to send file " << file << " to " - << ip << ", error: " << strerror(errno); + close(fd); + break; } + + LOG(WARNING) << "[replication] Fail to send file " << file << " to " + << ip << ", error: " << strerror(errno); close(fd); // Sleep if the speed of sending file is more than replication speed limit From 90c5e5af092a59c6b8275e3fde2ebde1871da889 Mon Sep 17 00:00:00 2001 From: wangyuan21 Date: Fri, 22 Apr 2022 17:31:01 +0800 Subject: [PATCH 2/2] Fix bugs --- src/redis_cmd.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/redis_cmd.cc b/src/redis_cmd.cc index 5509967fb4a..ff60a774cfe 100644 --- a/src/redis_cmd.cc +++ b/src/redis_cmd.cc @@ -4274,12 +4274,12 @@ class CommandFetchFile : public Commander { Util::SockSendFile(repl_fd, fd, file_size).IsOK()) { LOG(INFO) << "[replication] Succeed sending file " << file << " to " << ip; + } else { + LOG(WARNING) << "[replication] Fail to send file " << file << " to " + << ip << ", error: " << strerror(errno); close(fd); break; } - - LOG(WARNING) << "[replication] Fail to send file " << file << " to " - << ip << ", error: " << strerror(errno); close(fd); // Sleep if the speed of sending file is more than replication speed limit