Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RESTORE TTL is 0 with ASBTTL does not restore the key #1724

Merged

Conversation

enjoy-binbin
Copy link
Member

TTL is 0 mean the key is created without any expire.
ABSTTL mean the TTL should represent absolute Unix timestamp
in milliseconds in which the key will expire.

When typing TTL 0 and ABSTTL, kvrocks will not restore the
key, since we think the key is expired. However, in Redis,
ABSTTL is ignored when TTL is 0. (Although they seem to be
mutually exclusive)

127.0.0.1:6666> restore zset 0 "\x05\x03\x01cffffff\n@\x01b\x9a\x99\x99\x99\x99\x99\x01@\x01a\x9a\x99\x99\x99\x99\x99\xf1?\x0b\x00\x15\xae\xd7&\xda\x10\xe1\x03" absttl replace
OK
127.0.0.1:6666> ttl zset
(integer) -2
127.0.0.1:6666> exists zset
(integer) 0

127.0.0.1:6379> restore zset 0 "\x05\x03\x01cffffff\n@\x01b\x9a\x99\x99\x99\x99\x99\x01@\x01a\x9a\x99\x99\x99\x99\x99\xf1?\x0b\x00\x15\xae\xd7&\xda\x10\xe1\x03" absttl replace
OK
127.0.0.1:6379> exists zset
(integer) 1
127.0.0.1:6379> ttl zset
(integer) -1

-- after the fix
127.0.0.1:6666> restore zset 0 "\x05\x03\x01cffffff\n@\x01b\x9a\x99\x99\x99\x99\x99\x01@\x01a\x9a\x99\x99\x99\x99\x99\xf1?\x0b\x00\x15\xae\xd7&\xda\x10\xe1\x03" absttl replace
OK
127.0.0.1:6666> ttl zset
(integer) -1
127.0.0.1:6666> exists zset
(integer) 1

TTL is 0 mean the key is created without any expire.
ABSTTL mean the TTL should represent absolute Unix timestamp
in milliseconds in which the key will expire.

When typing TTL 0 and ABSTTL, kvrocks will not restore the
key, since we think the key is expired. However, in Redis,
ABSTTL is ignored when TTL is 0. (Although they seem to be
mutually exclusive)
Copy link
Member

@git-hulk git-hulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you.

@enjoy-binbin enjoy-binbin merged commit b1afbe3 into apache:unstable Sep 2, 2023
@enjoy-binbin enjoy-binbin deleted the fix_restore_ttl_0_with_absttl branch September 2, 2023 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants