arpit7275 / redis

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

Redis pub/sub ignores which database is currently selected #644

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What version of Redis you are using, in what kind of Operating System?
2.2.10 on Ubuntu 

What is the problem you are experiencing?
When you publish to a channel, subscriptions to that channel on other databases 
get the published message.

What steps will reproduce the problem?
Connection A:
SELECT 9
SUBSCRIBE FOO

Connection B:
SELECT 7
PUBLISH FOO BARBAR

Connection A will then get a "BARBAR" message on the "FOO" channel.

Do you have an INFO output? Please past it here.
redis_version:2.2.10
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:32
multiplexing_api:epoll
process_id:15140
uptime_in_seconds:1274513
uptime_in_days:14
lru_clock:1396609
used_cpu_sys:284.73
used_cpu_user:641.37
used_cpu_sys_childrens:0.00
used_cpu_user_childrens:0.18
connected_clients:6
connected_slaves:0
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
used_memory:610980
used_memory_human:596.66K
used_memory_rss:991232
mem_fragmentation_ratio:1.62
use_tcmalloc:0
loading:0
aof_enabled:0
changes_since_last_save:7200
bgsave_in_progress:0
last_save_time:1314200172
bgrewriteaof_in_progress:0
total_connections_received:1271
total_commands_processed:1149039
expired_keys:3940
evicted_keys:0
keyspace_hits:316093
keyspace_misses:647791
hash_max_zipmap_entries:512
hash_max_zipmap_value:64
pubsub_channels:1
pubsub_patterns:0
vm_enabled:0
role:master
allocation_stats:2=22839,4=68080,6=1,8=465263,9=26706,10=541562,11=125205,12=527
7816,13=328968,14=248564,15=201412,16=718764,17=40868,18=9321,19=11503,20=112851
,21=97669,22=49306,23=4878,24=194989,25=75555,26=67727,27=65481,28=10927,29=4675
4,30=96662,31=47682,32=70367,33=36369,34=38960,35=34098,36=65393,37=15695,38=113
987,39=21414,40=47603,41=53588,42=53921,43=67747,44=10597,45=8121,46=14426,47=12
289,48=76425,49=7750,50=3097,51=2020,52=1682,53=5837,54=418,55=2126,56=702,57=63
1,58=879,59=9182,60=1075,61=646,62=1488,63=731,64=16060,65=261,66=380,67=250,68=
40,69=20,70=228,71=1099,72=468,73=1074,74=3992,75=424,76=7182,77=12810,78=1719,7
9=11860,80=3658,81=447,82=350716,83=150,84=7322,85=1308,86=230,87=227,88=8,89=18
03,90=89,91=1544,92=43,93=584,94=16,95=412,96=422,97=215,99=2086,100=1718,101=12
343,102=3661,103=536,104=4335,105=652,106=8,107=25,108=219,109=1036,110=3,111=61
51,112=746,113=3679,114=205,115=263,117=796,120=215,125=430,128=10546,129=961,13
0=22,131=592,132=21,133=183,134=1,135=821,136=38,137=319,138=1035,139=1911,145=1
35,147=993,155=1,156=4,157=28,159=10,160=5,164=422,165=645,167=502,169=792,170=2
2,171=192,172=1,173=649,174=28,175=81,176=774,177=48,178=384,183=636,185=215,186
=422,189=346,191=42,193=278,195=17,197=81,198=767,199=104,200=379,201=12,205=26,
207=38,209=94,210=192,211=16,227=2,229=30,231=22,232=192,233=1,235=7,238=1,239=7
0,240=72,241=817,242=912,243=16,247=8,>=256=125106
db4:keys=52,expires=0
db5:keys=14,expires=14

If it is a crash, can you please paste the stack trace that you can find in
the log file or on standard output? This is really useful for us!

Please provide any additional information below.
I hope this is not a documentation bug (channels should be bound to databases, 
IMO). We run our application's redis integration tests locally using a separate 
database but the same redis server as our locally running sandbox web 
environment. For everything other than PUB/SUB this works perfectly. For 
PUB/SUB when there are namespace collisions (logging in with user id 1, running 
tests against user id 1) we see "ghost" messages that result in browser popups 
while we're browsing our local sandbox. Very annoying :)

Original issue reported on code.google.com by timothyfitz@gmail.com on 24 Aug 2011 at 3:45

GoogleCodeExporter commented 8 years ago
This is the expected behavior. Since pub/sub has no relation to the key space 
it was made to not interfere with it on any level, including database numbers. 
If you need scoping of some kind, you can use a prefix method and for instance 
prefix all channels with the name of the environment (test, staging, 
production, ...).

Original comment by pcnoordh...@gmail.com on 25 Aug 2011 at 8:13