This is an automated email from the ASF dual-hosted git repository.

binbin pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new f69982ee Fix RESTORE to create a key without expire under the same ms 
(#1705)
f69982ee is described below

commit f69982ee53b8a7a4c862014282bf2eebc1b5240c
Author: Binbin <[email protected]>
AuthorDate: Mon Aug 28 14:24:59 2023 +0800

    Fix RESTORE to create a key without expire under the same ms (#1705)
    
    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.
---
 src/commands/cmd_server.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/commands/cmd_server.cc b/src/commands/cmd_server.cc
index 7301432b..760adaed 100644
--- a/src/commands/cmd_server.cc
+++ b/src/commands/cmd_server.cc
@@ -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();

Reply via email to