chnaghong1990 / redis

Automatically exported from code.google.com/p/redis
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

A server can be a slave of itself #544

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It is possible to make a server be its own slave. IMHO this should not be 
allowed.
I'm seeing this with 2.2.5:

./redis-cli 
redis> slaveof 127.0.0.1 6379
OK
redis> info
connected_clients:1
connected_slaves:0
....
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0

and in the log, repeating infinitely:

[19171] 05 May 18:05:50 * SLAVE OF 127.0.0.1:6379 enabled (user request)
[19171] 05 May 18:05:51 * Connecting to MASTER...
[19171] 05 May 18:05:51 * MASTER <-> SLAVE sync started: SYNC sent
[19171] 05 May 18:05:51 - Accepted 127.0.0.1:45202
[19171] 05 May 18:05:51 # MASTER aborted replication with an error: ERR Can't 
SYNC while not connected with my master

Original issue reported on code.google.com by dvir...@gmail.com on 5 May 2011 at 3:19

GoogleCodeExporter commented 8 years ago
Hello, after all it is not a big problem as you can revert it with SLAVE OF 
NOONE. Instead preventing this is a big problem, as you need to send instance 
IDs or alike with the replication, as to try to understand this is your own 
address is more complex or even impossible if routing is "interesting" enough 
or you have TCP proxying.

So it is not perfect but neither a problem IMHO ;)

Thanks for reporting,
Salvatore

Original comment by anti...@gmail.com on 6 May 2011 at 8:48

GoogleCodeExporter commented 8 years ago
I suppose the client could run INFO and compare it to its own INFO, and this 
can pretty much tell you it's the same instance. I agree it's not that 
important, but it's something that actually happened to me (not using 
localhost, of course) :)

Original comment by dvir...@gmail.com on 6 May 2011 at 2:58