Merge pull request #3830 from oranagra/diskless_capa_pr

several bugfixes to diskless replication
This commit is contained in:
Salvatore Sanfilippo 2019-03-22 17:41:40 +01:00 committed by GitHub
commit fcac342955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -911,6 +911,16 @@ void unlinkClient(client *c) {
c->client_list_node = NULL; c->client_list_node = NULL;
} }
/* In the case of diskless replication the fork is writing to the
* sockets and just closing the fd isn't enough, if we don't also
* shutdown the socket the fork will continue to write to the slave
* and the salve will only find out that it was disconnected when
* it will finish reading the rdb. */
if ((c->flags & CLIENT_SLAVE) &&
(c->replstate == SLAVE_STATE_WAIT_BGSAVE_END)) {
shutdown(c->fd, SHUT_RDWR);
}
/* Unregister async I/O handlers and close the socket. */ /* Unregister async I/O handlers and close the socket. */
aeDeleteFileEvent(server.el,c->fd,AE_READABLE); aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE); aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);

View File

@ -593,6 +593,7 @@ int startBgsaveForReplication(int mincapa) {
client *slave = ln->value; client *slave = ln->value;
if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) { if (slave->replstate == SLAVE_STATE_WAIT_BGSAVE_START) {
slave->replstate = REPL_STATE_NONE;
slave->flags &= ~CLIENT_SLAVE; slave->flags &= ~CLIENT_SLAVE;
listDelNode(server.slaves,ln); listDelNode(server.slaves,ln);
addReplyError(slave, addReplyError(slave,