Don't do active replica work if we're not an active replica
Former-commit-id: 63dd1fb599cfe959c0298825ed56ab06335b3fd7
This commit is contained in:
parent
dfdc0cefdd
commit
4ed8f38a13
@ -380,22 +380,34 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
|
|||||||
|
|
||||||
// The code below used to be: snprintf(proto, sizeof(proto), "*5\r\n$7\r\nRREPLAY\r\n$%d\r\n%s\r\n$%lld\r\n", (int)strlen(uuid), uuid, cchbuf);
|
// The code below used to be: snprintf(proto, sizeof(proto), "*5\r\n$7\r\nRREPLAY\r\n$%d\r\n%s\r\n$%lld\r\n", (int)strlen(uuid), uuid, cchbuf);
|
||||||
// but that was much too slow
|
// but that was much too slow
|
||||||
char proto[1024] = "*5\r\n$7\r\nRREPLAY\r\n$36\r\n00000000-0000-0000-0000-000000000000\r\n$";
|
static const char *protoRREPLAY = "*5\r\n$7\r\nRREPLAY\r\n$36\r\n00000000-0000-0000-0000-000000000000\r\n$";
|
||||||
int cchProto = strlen(proto);
|
char proto[1024];
|
||||||
memcpy(proto + 22, uuid, 36); // Note UUID_STR_LEN includes the \0 trailing byte which we don't want
|
int cchProto = 0;
|
||||||
cchProto += ll2string(proto + cchProto, sizeof(proto)-cchProto, cchbuf);
|
if (!fSendRaw)
|
||||||
memcpy(proto + cchProto, "\r\n", 3);
|
{
|
||||||
cchProto += 2;
|
cchProto = strlen(protoRREPLAY);
|
||||||
|
memcpy(proto, protoRREPLAY, strlen(protoRREPLAY));
|
||||||
|
memcpy(proto + 22, uuid, 36); // Note UUID_STR_LEN includes the \0 trailing byte which we don't want
|
||||||
|
cchProto += ll2string(proto + cchProto, sizeof(proto)-cchProto, cchbuf);
|
||||||
|
memcpy(proto + cchProto, "\r\n", 3);
|
||||||
|
cchProto += 2;
|
||||||
|
}
|
||||||
|
|
||||||
long long master_repl_offset_start = g_pserver->master_repl_offset;
|
long long master_repl_offset_start = g_pserver->master_repl_offset;
|
||||||
|
|
||||||
char szDbNum[128];
|
char szDbNum[128];
|
||||||
int cchDbNum = writeProtoNum(szDbNum, sizeof(szDbNum), dictid);
|
int cchDbNum = 0;
|
||||||
|
if (!fSendRaw)
|
||||||
|
cchDbNum = writeProtoNum(szDbNum, sizeof(szDbNum), dictid);
|
||||||
|
|
||||||
|
|
||||||
char szMvcc[128];
|
char szMvcc[128];
|
||||||
incrementMvccTstamp();
|
int cchMvcc = 0;
|
||||||
int cchMvcc = writeProtoNum(szMvcc, sizeof(szMvcc), getMvccTstamp());
|
incrementMvccTstamp(); // Always increment MVCC tstamp so we're consistent with active and normal replication
|
||||||
|
if (!fSendRaw)
|
||||||
|
{
|
||||||
|
cchMvcc = writeProtoNum(szMvcc, sizeof(szMvcc), getMvccTstamp());
|
||||||
|
}
|
||||||
|
|
||||||
/* Write the command to the replication backlog if any. */
|
/* Write the command to the replication backlog if any. */
|
||||||
if (g_pserver->repl_backlog)
|
if (g_pserver->repl_backlog)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user