`
wx1568444409
  • 浏览: 14500 次
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

GET returns value for expired key (2.4.17)

 
阅读更多

昨天遇到redis一个奇怪问题,已超时的key居然还可以get到,导致程序逻辑错误,发现官方有人遇到和我一样的问题,最终确定是因系统设置了redis的maser和slave,当在slave上进行写入时就会遇到这样的问题。

ask:

Steps to reproduce:

  • set a key with an expiry
  • after expiry, issue GET for the key

$ redis-cli --version
redis-cli 2.4.17

$ redis-cli 
redis 127.0.0.1:6379> setex testkey 1 testvalue
OK
redis 127.0.0.1:6379> ttl testkey
(integer) -1
redis 127.0.0.1:6379> keys *
(empty list or set)
redis 127.0.0.1:6379> get testkey
"testvalue"
redis 127.0.0.1:6379> exists testkey
(integer) 1

replay:

Please can you use INFO to check what version is your Redis server? What you are experiencing is very strange and is well covered by the test, is the test passing? Thanks.

ask:

$ redis-cli info 
redis_version:2.4.17
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
gcc_version:4.6.1
process_id:1256
run_id:11cadfc4bd438f6d78ea90d04b95b5ccce2eace0
uptime_in_seconds:397475
uptime_in_days:4
lru_clock:823998
used_cpu_sys:89.27
used_cpu_user:56.49
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
connected_clients:1
connected_slaves:0
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
used_memory:721264
used_memory_human:704.36K
used_memory_rss:1949696
used_memory_peak:721480
used_memory_peak_human:704.57K
mem_fragmentation_ratio:2.70
mem_allocator:jemalloc-3.0.0
loading:0
aof_enabled:0
changes_since_last_save:0
bgsave_in_progress:0
last_save_time:1350369929
bgrewriteaof_in_progress:0
total_connections_received:7
total_commands_processed:163
expired_keys:0
evicted_keys:0
keyspace_hits:96
keyspace_misses:6
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:250
vm_enabled:0
role:slave
master_host:localhost
master_port:6380
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
master_link_down_since_seconds:397475
slave_priority:100
db0:keys=3,expires=3

replay:

Oh, ok, issue fixed, this is a slave not a master! :-)
You can write on a slave if it is not marked as read-only, but expires will never be expired as they can be expired only by master.

Closing the issue, thanks for reporting.

原文地址:https://github.com/antirez/redis/issues/712

转载于:https://my.oschina.net/u/569275/blog/100380

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics