pexpire/expire key with large number ttl will del key immediately #3739

Open
GitHubMota opened this Issue Jan 10, 2017 · 0 comments

Projects

None yet

1 participant

@GitHubMota

For pexpire, set pttl near INT64_MAX:
127.0.0.1:6379> set k v
OK
127.0.0.1:6379> pexpire k 9223372036854775807
(integer) 1
127.0.0.1:6379> get k
(nil)

For expire, set ttl near INT64_MAX/1000:
127.0.0.1:6379> set k v
OK
127.0.0.1:6379> expire k 9223372036854775
(integer) 1
127.0.0.1:6379> get k
(nil)
127.0.0.1:6379>

In redis source, when = mstime()+ttl(big number) will become negative, so when<mstime(), and del the key immediately.
For this situation, I think it's better to forbid this operation by return ERR. Nobody expect to del the key with expire it with big ttl instead of a negative ttl. He probably excute this by mistake.

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