Skip to content

Commit 18dbbaf

Browse files
visualYJDyuhaijun999
authored andcommitted
[fix][store] Fixup the dead loop
1 parent f22dce4 commit 18dbbaf

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/engine/concurrency_manager.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ namespace dingodb {
2222
// lock_entry.rw_lock has already write locked
2323
void ConcurrencyManager::LockKey(const std::string& key, LockEntryPtr lock_entry) {
2424
RWLockWriteGuard guard(&rw_lock_);
25+
2526
lock_table_[key] = lock_entry;
2627
}
2728

2829
void ConcurrencyManager::UnlockKeys(const std::vector<std::string>& keys) {
2930
RWLockWriteGuard guard(&rw_lock_);
31+
3032
for (auto const& key : keys) {
3133
auto it = lock_table_.find(key);
3234
if (it != lock_table_.end()) {
@@ -42,6 +44,7 @@ bool ConcurrencyManager::CheckKeys(const std::vector<std::string>& keys, pb::sto
4244
std::vector<LockEntryPtr> lock_entrys;
4345
{
4446
RWLockReadGuard guard(&rw_lock_);
47+
4548
for (auto const& key : keys) {
4649
auto it = lock_table_.find(key);
4750
if (it != lock_table_.end()) {
@@ -55,6 +58,7 @@ bool ConcurrencyManager::CheckKeys(const std::vector<std::string>& keys, pb::sto
5558
continue;
5659
}
5760
RWLockReadGuard guard(&lock_entry->rw_lock);
61+
5862
if (TxnEngineHelper::CheckLockConflict(lock_entry->lock_info, isolation_level, start_ts, resolved_locks,
5963
txn_result_info)) {
6064
return true;
@@ -71,9 +75,11 @@ bool ConcurrencyManager::CheckRange(const std::string& start_key, const std::str
7175
std::vector<LockEntryPtr> lock_entrys;
7276
{
7377
RWLockReadGuard guard(&rw_lock_);
78+
7479
auto it = lock_table_.lower_bound(start_key);
75-
while (it != lock_table_.end() && it->first <= end_key) {
80+
while (it != lock_table_.end() && it->first < end_key) {
7681
lock_entrys.push_back(it->second);
82+
++it;
7783
}
7884
}
7985

src/engine/concurrency_manager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "proto/store.pb.h"
2525

2626
namespace dingodb {
27+
2728
class ConcurrencyManager {
2829
public:
2930
ConcurrencyManager() = default;
@@ -43,7 +44,7 @@ class ConcurrencyManager {
4344
RWLock rw_lock;
4445
std::atomic<bool> is_deleted{false}; // Whether the marker has been is_deleted (i.e., removed from the map)
4546
};
46-
47+
4748
using LockEntryPtr = std::shared_ptr<LockEntry>;
4849

4950
void LockKey(const std::string& key, LockEntryPtr lock_entry);
@@ -58,9 +59,8 @@ class ConcurrencyManager {
5859
int64_t start_ts, const std::set<int64_t>& resolved_locks, pb::store::TxnResultInfo& txn_result_info);
5960

6061
private:
61-
// key->lock_info pb::store::LockInfo
62-
std::map<std::string, LockEntryPtr>
63-
lock_table_; // Ordered storage of locked keys (supporting range queries)
62+
// key->lock_info Ordered storage of locked keys (supporting range queries)
63+
std::map<std::string, LockEntryPtr> lock_table_;
6464
RWLock rw_lock_;
6565
};
6666

0 commit comments

Comments
 (0)