bestvivi / redis

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

Replicate a list value #527

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Redis version: 2.2.4

Mismatch value after replicating a list value.  Steps:
1. Master: 
redis> lpush list 1
(integer) 1
redis> lpush list 2
(integer) 2
redis> lrange list 0 3
1) "2"
2) "1"

2. Slave:
redis> lrange list 0 3
1) "2"
2) "1"
redis> lpush list 3
(integer) 3
redis> lrange list 0 3
1) "3"
2) "2"
3) "1"

3. Master:
redis> lset list 0 5
OK
redis> lrange list 0 3
1) "5"
2) "1"

4. Slave:
redis> lrange list 0 3
1) "5"
2) "2"
3) "1"

Yet it's okay after restarting slave.

Original issue reported on code.google.com by lgx...@gmail.com on 19 Apr 2011 at 7:25

GoogleCodeExporter commented 9 years ago
This is not a bug. Slaves don't write their updates to the master, but do allow 
for local writes. Upon slave restart, or even a "slaveof no one" followed by 
"slaveof masterhost masterport", the slave is re-synchronized to the master.

Original comment by josiah.c...@gmail.com on 19 Apr 2011 at 7:47

GoogleCodeExporter commented 9 years ago
I think after replica, the list value on slave should be same with master.
It's local update should be lost and replace by master.

So it's value should be:

4. Slave:
redis> lrange list 0 3
1) "5"
2) "1"

Original comment by lgx...@gmail.com on 20 Apr 2011 at 2:04

GoogleCodeExporter commented 9 years ago
As Josiah mentions, this is expected behavior. If you want to write against 
your slave because that makes sense, you can and Redis does not interfere. If 
you want to have the slave exactly mirror the data on the master, you should 
not write to slaves.

Original comment by pcnoordh...@gmail.com on 20 Apr 2011 at 7:52

GoogleCodeExporter commented 9 years ago
Okay, thanks for reply.

By the way, do you have any plan to support partial replica?  For example, only 
replicate some selected databases? 

Original comment by lgx...@gmail.com on 20 Apr 2011 at 8:17

GoogleCodeExporter commented 9 years ago
At some point in the future we will likely deprecate multiple databases, as it 
is a bad practice for separation and adds (imo unnecessary) complexity to 
Redis. Rather, it is recommended to use multiple Redis instances for separation 
of data, since it has a very low memory footprint and moves the complexity to 
the OS.

Original comment by pcnoordh...@gmail.com on 20 Apr 2011 at 8:23

GoogleCodeExporter commented 9 years ago
Oh, I see. Thanks.

Original comment by lgx...@gmail.com on 20 Apr 2011 at 8:34