mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Replication: send REPLCONF ACK to master.
This commit is contained in:
parent
6b4635f4f5
commit
0292c5f7ae
@ -127,7 +127,8 @@ redisClient *createClient(int fd) {
|
|||||||
* data should be appended to the output buffers. */
|
* data should be appended to the output buffers. */
|
||||||
int prepareClientToWrite(redisClient *c) {
|
int prepareClientToWrite(redisClient *c) {
|
||||||
if (c->flags & REDIS_LUA_CLIENT) return REDIS_OK;
|
if (c->flags & REDIS_LUA_CLIENT) return REDIS_OK;
|
||||||
if (c->flags & REDIS_MASTER) return REDIS_ERR;
|
if ((c->flags & REDIS_MASTER) &&
|
||||||
|
!(c->flags & REDIS_MASTER_FORCE_REPLY)) return REDIS_ERR;
|
||||||
if (c->fd <= 0) return REDIS_ERR; /* Fake client */
|
if (c->fd <= 0) return REDIS_ERR; /* Fake client */
|
||||||
if (c->bufpos == 0 && listLength(c->reply) == 0 &&
|
if (c->bufpos == 0 && listLength(c->reply) == 0 &&
|
||||||
(c->replstate == REDIS_REPL_NONE ||
|
(c->replstate == REDIS_REPL_NONE ||
|
||||||
|
14
src/redis.c
14
src/redis.c
@ -1868,6 +1868,15 @@ int processCommand(redisClient *c) {
|
|||||||
call(c,REDIS_CALL_FULL);
|
call(c,REDIS_CALL_FULL);
|
||||||
if (listLength(server.ready_keys))
|
if (listLength(server.ready_keys))
|
||||||
handleClientsBlockedOnLists();
|
handleClientsBlockedOnLists();
|
||||||
|
/* Acknowledge the master about the execution of this command. */
|
||||||
|
if (c->flags & REDIS_MASTER) {
|
||||||
|
c->flags |= REDIS_MASTER_FORCE_REPLY;
|
||||||
|
addReplyMultiBulkLen(c,3);
|
||||||
|
addReplyBulkCString(c,"REPLCONF");
|
||||||
|
addReplyBulkCString(c,"ACK");
|
||||||
|
addReplyBulkLongLong(c,c->reploff);
|
||||||
|
c->flags &= ~REDIS_MASTER_FORCE_REPLY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return REDIS_OK;
|
return REDIS_OK;
|
||||||
}
|
}
|
||||||
@ -2337,8 +2346,9 @@ sds genRedisInfoString(char *section) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (state == NULL) continue;
|
if (state == NULL) continue;
|
||||||
info = sdscatprintf(info,"slave%d:%s,%d,%s\r\n",
|
info = sdscatprintf(info,"slave%d:%s,%d,%s,%lld\r\n",
|
||||||
slaveid,ip,slave->slave_listening_port,state);
|
slaveid,ip,slave->slave_listening_port,state,
|
||||||
|
slave->repl_ack_off);
|
||||||
slaveid++;
|
slaveid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,6 +213,7 @@
|
|||||||
#define REDIS_CLOSE_ASAP (1<<10)/* Close this client ASAP */
|
#define REDIS_CLOSE_ASAP (1<<10)/* Close this client ASAP */
|
||||||
#define REDIS_UNIX_SOCKET (1<<11) /* Client connected via Unix domain socket */
|
#define REDIS_UNIX_SOCKET (1<<11) /* Client connected via Unix domain socket */
|
||||||
#define REDIS_DIRTY_EXEC (1<<12) /* EXEC will fail for errors while queueing */
|
#define REDIS_DIRTY_EXEC (1<<12) /* EXEC will fail for errors while queueing */
|
||||||
|
#define REDIS_MASTER_FORCE_REPLY (1<<13) /* Queue replies even if is master */
|
||||||
|
|
||||||
/* Client request types */
|
/* Client request types */
|
||||||
#define REDIS_REQ_INLINE 1
|
#define REDIS_REQ_INLINE 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user