Skip to content

Commit

Permalink
fix lock
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxianrong committed Mar 13, 2024
1 parent f098309 commit 329b885
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 62 deletions.
14 changes: 4 additions & 10 deletions src/storage/src/redis_hashes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ Status RedisHashes::HDel(const Slice& key, const std::vector<std::string>& field
std::string meta_value;
int32_t del_cnt = 0;
int32_t version = 0;
ScopeRecordLock l(lock_mgr_, key);
ScopeSnapshot ss(db_, &snapshot);
read_options.snapshot = snapshot;
Status s = db_->Get(read_options, handles_[0], key, &meta_value);
Expand Down Expand Up @@ -357,7 +356,6 @@ Status RedisHashes::HGetallWithTTL(const Slice& key, std::vector<FieldValue>* fv
Status RedisHashes::HIncrby(const Slice& key, const Slice& field, int64_t value, int64_t* ret) {
*ret = 0;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

int32_t version = 0;
uint32_t statistic = 0;
Expand Down Expand Up @@ -428,7 +426,6 @@ Status RedisHashes::HIncrby(const Slice& key, const Slice& field, int64_t value,
Status RedisHashes::HIncrbyfloat(const Slice& key, const Slice& field, const Slice& by, std::string* new_value) {
new_value->clear();
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

int32_t version = 0;
uint32_t statistic = 0;
Expand Down Expand Up @@ -606,7 +603,6 @@ Status RedisHashes::HMSet(const Slice& key, const std::vector<FieldValue>& fvs)
}

rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

int32_t version = 0;
std::string meta_value;
Expand Down Expand Up @@ -665,7 +661,6 @@ Status RedisHashes::HMSet(const Slice& key, const std::vector<FieldValue>& fvs)

Status RedisHashes::HSet(const Slice& key, const Slice& field, const Slice& value, int32_t* res) {
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

int32_t version = 0;
uint32_t statistic = 0;
Expand Down Expand Up @@ -724,7 +719,6 @@ Status RedisHashes::HSet(const Slice& key, const Slice& field, const Slice& valu

Status RedisHashes::HSetnx(const Slice& key, const Slice& field, const Slice& value, int32_t* ret) {
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

int32_t version = 0;
std::string meta_value;
Expand Down Expand Up @@ -1160,7 +1154,7 @@ Status RedisHashes::PKRScanRange(const Slice& key_start, const Slice& key_end, c

Status RedisHashes::Expire(const Slice& key, int32_t ttl) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedHashesMetaValue parsed_hashes_meta_value(&meta_value);
Expand All @@ -1183,7 +1177,7 @@ Status RedisHashes::Expire(const Slice& key, int32_t ttl) {

Status RedisHashes::Del(const Slice& key) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedHashesMetaValue parsed_hashes_meta_value(&meta_value);
Expand Down Expand Up @@ -1278,7 +1272,7 @@ bool RedisHashes::PKExpireScan(const std::string& start_key, int32_t min_timesta

Status RedisHashes::Expireat(const Slice& key, int32_t timestamp) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedHashesMetaValue parsed_hashes_meta_value(&meta_value);
Expand All @@ -1300,7 +1294,7 @@ Status RedisHashes::Expireat(const Slice& key, int32_t timestamp) {

Status RedisHashes::Persist(const Slice& key) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedHashesMetaValue parsed_hashes_meta_value(&meta_value);
Expand Down
20 changes: 7 additions & 13 deletions src/storage/src/redis_lists.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ Status RedisLists::LInsert(const Slice& key, const BeforeOrAfter& before_or_afte
const std::string& value, int64_t* ret) {
*ret = 0;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
std::string meta_value;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
Expand Down Expand Up @@ -349,7 +348,6 @@ Status RedisLists::LPop(const Slice& key, int64_t count, std::vector<std::string
elements->clear();

rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

std::string meta_value;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
Expand Down Expand Up @@ -392,7 +390,6 @@ Status RedisLists::LPop(const Slice& key, int64_t count, std::vector<std::string
Status RedisLists::LPush(const Slice& key, const std::vector<std::string>& values, uint64_t* ret) {
*ret = 0;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

uint64_t index = 0;
int32_t version = 0;
Expand Down Expand Up @@ -436,7 +433,6 @@ Status RedisLists::LPush(const Slice& key, const std::vector<std::string>& value
Status RedisLists::LPushx(const Slice& key, const std::vector<std::string>& values, uint64_t* len) {
*len = 0;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);

std::string meta_value;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
Expand Down Expand Up @@ -579,7 +575,6 @@ Status RedisLists::LRangeWithTTL(const Slice& key, int64_t start, int64_t stop,
Status RedisLists::LRem(const Slice& key, int64_t count, const Slice& value, uint64_t* ret) {
*ret = 0;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
std::string meta_value;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
Expand Down Expand Up @@ -695,7 +690,6 @@ Status RedisLists::LRem(const Slice& key, int64_t count, const Slice& value, uin

Status RedisLists::LSet(const Slice& key, int64_t index, const Slice& value) {
uint32_t statistic = 0;
ScopeRecordLock l(lock_mgr_, key);
std::string meta_value;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
Expand Down Expand Up @@ -724,7 +718,7 @@ Status RedisLists::LSet(const Slice& key, int64_t index, const Slice& value) {

Status RedisLists::LTrim(const Slice& key, int64_t start, int64_t stop) {
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
;

uint32_t statistic = 0;
std::string meta_value;
Expand Down Expand Up @@ -786,7 +780,7 @@ Status RedisLists::RPop(const Slice& key, int64_t count, std::vector<std::string
elements->clear();

rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
;

std::string meta_value;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
Expand Down Expand Up @@ -986,7 +980,7 @@ Status RedisLists::RPushx(const Slice& key, const std::vector<std::string>& valu
*len = 0;
rocksdb::WriteBatch batch;

ScopeRecordLock l(lock_mgr_, key);
;
std::string meta_value;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
Expand Down Expand Up @@ -1120,7 +1114,7 @@ Status RedisLists::PKRScanRange(const Slice& key_start, const Slice& key_end, co

Status RedisLists::Expire(const Slice& key, int32_t ttl) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedListsMetaValue parsed_lists_meta_value(&meta_value);
Expand All @@ -1143,7 +1137,7 @@ Status RedisLists::Expire(const Slice& key, int32_t ttl) {

Status RedisLists::Del(const Slice& key) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedListsMetaValue parsed_lists_meta_value(&meta_value);
Expand Down Expand Up @@ -1237,7 +1231,7 @@ bool RedisLists::PKExpireScan(const std::string& start_key, int32_t min_timestam

Status RedisLists::Expireat(const Slice& key, int32_t timestamp) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedListsMetaValue parsed_lists_meta_value(&meta_value);
Expand All @@ -1259,7 +1253,7 @@ Status RedisLists::Expireat(const Slice& key, int32_t timestamp) {

Status RedisLists::Persist(const Slice& key) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedListsMetaValue parsed_lists_meta_value(&meta_value);
Expand Down
15 changes: 7 additions & 8 deletions src/storage/src/redis_sets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ rocksdb::Status RedisSets::SAdd(const Slice& key, const std::vector<std::string>
}

rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
int32_t version = 0;
std::string meta_value;
rocksdb::Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
Expand Down Expand Up @@ -841,7 +840,7 @@ rocksdb::Status RedisSets::SPop(const Slice& key, std::vector<std::string>* memb

std::string meta_value;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
;

uint64_t start_us = pstd::NowMicros();
Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
Expand Down Expand Up @@ -935,7 +934,7 @@ rocksdb::Status RedisSets::SRandmember(const Slice& key, int32_t count, std::vec

std::string meta_value;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
;
std::vector<int32_t> targets;
std::unordered_set<int32_t> unique;

Expand Down Expand Up @@ -996,7 +995,7 @@ rocksdb::Status RedisSets::SRandmember(const Slice& key, int32_t count, std::vec
rocksdb::Status RedisSets::SRem(const Slice& key, const std::vector<std::string>& members, int32_t* ret) {
*ret = 0;
rocksdb::WriteBatch batch;
ScopeRecordLock l(lock_mgr_, key);
;

int32_t version = 0;
uint32_t statistic = 0;
Expand Down Expand Up @@ -1345,7 +1344,7 @@ rocksdb::Status RedisSets::PKRScanRange(const Slice& key_start, const Slice& key

rocksdb::Status RedisSets::Expire(const Slice& key, int32_t ttl) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
rocksdb::Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
Expand All @@ -1368,7 +1367,7 @@ rocksdb::Status RedisSets::Expire(const Slice& key, int32_t ttl) {

rocksdb::Status RedisSets::Del(const Slice& key) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
rocksdb::Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
Expand Down Expand Up @@ -1462,7 +1461,7 @@ bool RedisSets::PKExpireScan(const std::string& start_key, int32_t min_timestamp

rocksdb::Status RedisSets::Expireat(const Slice& key, int32_t timestamp) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
rocksdb::Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
Expand All @@ -1484,7 +1483,7 @@ rocksdb::Status RedisSets::Expireat(const Slice& key, int32_t timestamp) {

rocksdb::Status RedisSets::Persist(const Slice& key) {
std::string meta_value;
ScopeRecordLock l(lock_mgr_, key);
;
rocksdb::Status s = db_->Get(default_read_options_, handles_[0], key, &meta_value);
if (s.ok()) {
ParsedSetsMetaValue parsed_sets_meta_value(&meta_value);
Expand Down
Loading

0 comments on commit 329b885

Please sign in to comment.