New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redis-cli --rdb fails if server sends a ping #893

Merged
merged 1 commit into from Jan 18, 2013

Conversation

Projects
None yet
2 participants
@nparry
Contributor

nparry commented Jan 18, 2013

Redis pings slaves in "pre-synchronization stage" with newlines. (See
https://github.com/antirez/redis/blob/2.6.9/src/replication.c#L814)
However, redis-cli does not expect this - it sees the newline as the end
of the bulk length line, and ends up returning 0 as bulk the length.
This manifests as the following when running redis-cli:

$ ./src/redis-cli --rdb some_file
SYNC sent to master, writing 0 bytes to 'some_file'
Transfer finished with success.

With this commit, we just ignore leading newlines while reading the bulk
length line.

To reproduce the problem, load enough data into Redis so that the
preparation of the RDB snapshot takes long enough for a ping to occur
while redis-cli is waiting for the data.

redis-cli --rdb fails if server sends a ping
Redis pings slaves in "pre-synchronization stage" with newlines. (See
https://github.com/antirez/redis/blob/2.6.9/src/replication.c#L814)
However, redis-cli does not expect this - it sees the newline as the end
of the bulk length line, and ends up returning 0 as bulk the length.
This manifests as the following when running redis-cli:

    $ ./src/redis-cli --rdb some_file
    SYNC sent to master, writing 0 bytes to 'some_file'
    Transfer finished with success.

With this commit, we just ignore leading newlines while reading the bulk
length line.

To reproduce the problem, load enough data into Redis so that the
preparation of the RDB snapshot takes long enough for a ping to occur
while redis-cli is waiting for the data.

antirez added a commit that referenced this pull request Jan 18, 2013

Merge pull request #893 from nparry/fix-redis-cli-rdb
redis-cli --rdb fails if server sends a ping

@antirez antirez merged commit 21b3ff9 into antirez:unstable Jan 18, 2013

@antirez

This comment has been minimized.

Show comment
Hide comment
@antirez

antirez Jan 18, 2013

Owner

Good work @nparry! Merged.

Owner

antirez commented Jan 18, 2013

Good work @nparry! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment