13 Commits

Author SHA1 Message Date
antirez
85b50ca125 syncWithMaster(): non blocking state machine. 2015-08-06 18:12:20 +02:00
antirez
1e792aa02d Fix synchronous readline "\n" handling.
Our function to read a line with a timeout handles newlines as requests
to refresh the timeout, however the code kept subtracting the buffer
size left every time a newline was received, for a bug in the loop
logic. Fixed by this commit.
2015-08-05 16:51:50 +02:00
antirez
142611882a PSYNC initial offset fix.
This commit attempts to fix a bug involving PSYNC and diskless
replication (currently experimental) found by Yuval Inbar from Redis Labs
and that was later found to have even more far reaching effects (the bug also
exists when diskstore is off).

The gist of the bug is that, a Redis master replies with +FULLRESYNC to
a PSYNC attempt that fails and requires a full resynchronization.
However, the baseline offset sent along with FULLRESYNC was always the
current master replication offset. This is not ok, because there are
many reasosn that may delay the RDB file creation. And... guess what,
the master offset we communicate must be the one of the time the RDB
was created. So for example:

1) When the BGSAVE for replication is delayed since there is one
   already but is not good for replication.
2) When the BGSAVE is not needed as we attach one currently ongoing.
3) When because of diskless replication the BGSAVE is delayed.

In all the above cases the PSYNC reply is wrong and the slave may
reconnect later claiming to need a wrong offset: this may cause
data curruption later.
2015-08-04 17:06:10 +02:00
antirez
3064487047 RDMF: more names updated. 2015-07-27 15:03:10 +02:00
antirez
6a424b5e36 RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
antirez
13c9702b41 syncReadLine(): actually enforce buffer size limits. 2014-10-16 17:35:29 +02:00
antirez
1c94889182 No more trailing spaces in Redis source code. 2014-06-26 18:48:40 +02:00
antirez
dbe891ce05 syncio.c read / write functions reworked for correctness and performance.
The new implementation start reading / writing before blocking with
aeWait(), likely the descriptor can accept writes or has buffered data
inside and we can go faster, otherwise we get an error and wait.

This change has effects on speed but also on correctness: on socket
errors when we perform non blocking connect(2) write is performed ASAP
and the error is returned ASAP before waiting.

So the practical effect is that now a Redis slave is more available if it
can not connect to the master, previously the slave continued to block on
syncWrite() trying to send SYNC, and serving commands very slowly.
2012-05-02 22:41:50 +02:00
antirez
8d50449cf8 Better syncio.c with millisecond resolution. 2012-03-31 11:21:45 +02:00
Pieter Noordhuis
a67b0922d7 Use rio.h functions in aof.c 2011-05-14 12:36:22 +02:00
antirez
b2b9d54320 Cluster branch merged to unstable. 2011-03-29 17:51:15 +02:00
antirez
64a61269df more generally usable i/o functions moved to syncio.c 2010-10-25 10:53:28 +02:00
antirez
db874d3c9a synchronous I/O networking functions originally used just for replication refactored in a file as generally useful, they are used in the cluster branch for MIGRATE. 2010-10-24 16:22:52 +02:00