Skip to content

Commit

Permalink
Fix RESTORE to create a key without expire under the same ms (#1705)
Browse files Browse the repository at this point in the history
I am unable to reproduce it, but if the ttl_ms (absttl) passed in
happens to be in the same ms as GetTimeStampMS, the `ttl_ms < now`
will be false and `ttl_ms -= now` will make ttl_ms become 0 and then
we will create a key without any expire.

It is off by one bug.
  • Loading branch information
enjoy-binbin authored Aug 28, 2023
1 parent d5ad497 commit f69982e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/commands/cmd_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ class CommandRestore : public Commander {
}
if (absttl_) {
auto now = util::GetTimeStampMS();
if (ttl_ms_ < now) {
if (ttl_ms_ <= now) {
// return ok if the ttl is already expired
*output = redis::SimpleString("OK");
return Status::OK();
Expand Down

0 comments on commit f69982e

Please sign in to comment.