mirror of
https://github.com/fluencelabs/redis
synced 2025-06-17 03:01:20 +00:00
PSYNC2: stop sending newlines to sub-slaves when master is down.
This actually includes two changes: 1) No newlines to take the master-slave link up when the upstream master is down. Doing this is dangerous because the sub-slave often is received replication protocol for an half-command, so can't receive newlines without desyncing the replication link, even with the code in order to cancel out the bytes that PSYNC2 was using. Moreover this is probably also not needed/sane, because anyway the slave can keep serving requests, and because if it's configured to don't serve stale data, it's a good idea, actually, to break the link. 2) When a +CONTINUE with a different ID is received, we now break connection with the sub-slaves: they need to be notified as well. This was part of the original specification but for some reason it was not implemented in the code, and was alter found as a PSYNC2 bug in the integration testing.
This commit is contained in:
@ -1031,7 +1031,7 @@ int processInlineBuffer(client *c) {
|
||||
char *newline;
|
||||
int argc, j;
|
||||
sds *argv, aux;
|
||||
size_t querylen, protolen;
|
||||
size_t querylen;
|
||||
|
||||
/* Search for end of line */
|
||||
newline = strchr(c->querybuf,'\n');
|
||||
@ -1044,7 +1044,6 @@ int processInlineBuffer(client *c) {
|
||||
}
|
||||
return C_ERR;
|
||||
}
|
||||
protolen = (newline - c->querybuf)+1; /* Total protocol bytes of command. */
|
||||
|
||||
/* Handle the \r\n case. */
|
||||
if (newline && newline != c->querybuf && *(newline-1) == '\r')
|
||||
@ -1067,15 +1066,6 @@ int processInlineBuffer(client *c) {
|
||||
if (querylen == 0 && c->flags & CLIENT_SLAVE)
|
||||
c->repl_ack_time = server.unixtime;
|
||||
|
||||
/* Newline from masters can be used to prevent timeouts, but should
|
||||
* not affect the replication offset since they are always sent
|
||||
* "out of band" directly writing to the socket and without passing
|
||||
* from the output buffers. */
|
||||
if (querylen == 0 && c->flags & CLIENT_MASTER) {
|
||||
c->reploff -= protolen;
|
||||
while (protolen--) chopReplicationBacklog();
|
||||
}
|
||||
|
||||
/* Leave data after the first line of the query in the buffer */
|
||||
sdsrange(c->querybuf,querylen+2,-1);
|
||||
|
||||
|
Reference in New Issue
Block a user