Skip to content

Commit fcac342

Browse files
authored
Merge pull request redis#3830 from oranagra/diskless_capa_pr
several bugfixes to diskless replication
2 parents 122f428 + 29b0a57 commit fcac342

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/networking.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,16 @@ void unlinkClient(client *c) {
911911
c->client_list_node = NULL;
912912
}
913913

914+
/* In the case of diskless replication the fork is writing to the
915+
* sockets and just closing the fd isn't enough, if we don't also
916+
* shutdown the socket the fork will continue to write to the slave
917+
* and the salve will only find out that it was disconnected when
918+
* it will finish reading the rdb. */
919+
if ((c->flags & CLIENT_SLAVE) &&
920+
(c->replstate == SLAVE_STATE_WAIT_BGSAVE_END)) {
921+
shutdown(c->fd, SHUT_RDWR);
922+
}
923+
914924
/* Unregister async I/O handlers and close the socket. */
915925
aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
916926
aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);

src/replication.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ int startBgsaveForReplication(int mincapa) {
593593
client *slave = ln->value;
594594

595595
if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) {
596+
slave->replstate = REPL_STATE_NONE;
596597
slave->flags &= ~CLIENT_SLAVE;
597598
listDelNode(server.slaves,ln);
598599
addReplyError(slave,

0 commit comments

Comments
 (0)