From f69982ee53b8a7a4c862014282bf2eebc1b5240c Mon Sep 17 00:00:00 2001 From: Binbin Date: Mon, 28 Aug 2023 14:24:59 +0800 Subject: [PATCH] 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 7301432bc4f..760adaed60f 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();