diff --git a/src/redis_cmd.cc b/src/redis_cmd.cc index ff4b52f5c14..8c164a39c7a 100644 --- a/src/redis_cmd.cc +++ b/src/redis_cmd.cc @@ -4321,7 +4321,7 @@ CommandAttributes redisCommandTable[] = { ADD_CMD("setex", 4, "write", 1, 1, 1, CommandSetEX), ADD_CMD("psetex", 4, "write", 1, 1, 1, CommandPSetEX), ADD_CMD("setnx", 3, "write", 1, 1, 1, CommandSetNX), - ADD_CMD("msetnx", -3, "write", 1, -1, 2, CommandMSetNX), + ADD_CMD("msetnx", -3, "write exclusive", 1, -1, 2, CommandMSetNX), ADD_CMD("mset", -3, "write", 1, -1, 2, CommandMSet), ADD_CMD("incrby", 3, "write", 1, 1, 1, CommandIncrBy), ADD_CMD("incrbyfloat", 3, "write", 1, 1, 1, CommandIncrByFloat), diff --git a/src/redis_string.cc b/src/redis_string.cc index d56a8c4b211..773aef7d6db 100644 --- a/src/redis_string.cc +++ b/src/redis_string.cc @@ -354,6 +354,9 @@ rocksdb::Status String::MSetNX(const std::vector &pairs, int ttl, in for (StringPair pair : pairs) { AppendNamespacePrefix(pair.key, &ns_key); LockGuard guard(storage_->GetLockManager(), ns_key); + if (Exists({pair.key}, &exists).ok() && exists == 1) { + return rocksdb::Status::OK(); + } std::string bytes; Metadata metadata(kRedisString, false); metadata.expire = expire;