You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by wa...@apache.org on 2022/06/28 13:13:10 UTC
[incubator-kvrocks] branch unstable updated: Use lock guard for zremrangebylex command (#686)
This is an automated email from the ASF dual-hosted git repository.
wangyuan pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new a25faa1 Use lock guard for zremrangebylex command (#686)
a25faa1 is described below
commit a25faa1f10eff4a40843ecdeca1b3cdbf60328ed
Author: Wang Yuan <wa...@baidu.com>
AuthorDate: Tue Jun 28 21:13:04 2022 +0800
Use lock guard for zremrangebylex command (#686)
zremrangebylex command will change the zset data without lock guard,
this may cause zset data error.
---
src/redis_zset.cc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/redis_zset.cc b/src/redis_zset.cc
index 8bcf660..819f830 100644
--- a/src/redis_zset.cc
+++ b/src/redis_zset.cc
@@ -418,6 +418,11 @@ rocksdb::Status ZSet::RangeByLex(const Slice &user_key,
std::string ns_key;
AppendNamespacePrefix(user_key, &ns_key);
+ std::unique_ptr<LockGuard> lock_guard;
+ if (spec.removed) {
+ lock_guard = std::unique_ptr<LockGuard>(
+ new LockGuard(storage_->GetLockManager(), ns_key));
+ }
ZSetMetadata metadata(false);
rocksdb::Status s = GetMetadata(ns_key, &metadata);
if (!s.ok()) return s.IsNotFound() ? rocksdb::Status::OK() : s;