Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva
F(type_write_del, {"type", "write_del"}), \
F(type_lock_del, {"type", "lock_del"}), \
F(type_pessimistic_lock_put, {"type", "pessimistic_lock_put"}), \
F(type_shared_lock_put, {"type", "shared_lock_put"}), \
F(type_lock_replaced, {"type", "lock_replaced"}), \
F(type_default_del, {"type", "default_del"}), \
F(type_apply_snapshot, {"type", "apply_snapshot"}), \
Expand Down
11 changes: 10 additions & 1 deletion dbms/src/Storages/KVStore/TiKVHelpers/DecodedLockCFValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ namespace RecordKVFormat
case LockType::Pessimistic:
lock_type = kvrpcpb::Op::PessimisticLock;
break;
case LockType::Shared:
// Skip parsing shared locks as they do not block any read requests.
res.lock_type = kvrpcpb::Op::SharedLock;
return inner;
}
res.lock_type = lock_type;
res.primary_lock = readVarString<std::string_view>(data, len);
Expand Down Expand Up @@ -166,6 +170,10 @@ DecodedLockCFValue::DecodedLockCFValue(std::shared_ptr<const TiKVKey> key_, std:
{
GET_METRIC(tiflash_raft_process_keys, type_pessimistic_lock_put).Increment(1);
}
else if (parsed->lock_type == kvrpcpb::Op::SharedLock)
{
GET_METRIC(tiflash_raft_process_keys, type_shared_lock_put).Increment(1);
}
if (parsed->generation == 0)
{
// It is not a large txn, we cache the parsed lock.
Expand Down Expand Up @@ -244,7 +252,8 @@ void DecodedLockCFValue::Inner::getLockInfoPtr(
LockInfoPtr & res) const
{
res = nullptr;
if (lock_version > query.read_tso || lock_type == kvrpcpb::Op::Lock || lock_type == kvrpcpb::Op::PessimisticLock)
if (lock_version > query.read_tso || lock_type == kvrpcpb::Op::Lock || lock_type == kvrpcpb::Op::PessimisticLock
|| lock_type == kvrpcpb::Op::SharedLock)
return;
if (min_commit_ts > query.read_tso)
return;
Expand Down
1 change: 1 addition & 0 deletions dbms/src/Storages/KVStore/TiKVHelpers/TiKVRecordFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ enum LockType : UInt8
Delete = 'D',
Lock = 'L',
Pessimistic = 'S',
Shared = 'H',
};

struct InnerDecodedWriteCFValue
Expand Down
13 changes: 13 additions & 0 deletions dbms/src/Storages/KVStore/tests/gtest_kvstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,19 @@ TEST_F(RegionKVStoreOldTest, RegionReadWrite)
}
region->clearAllData();
}
{
region->insertFromSnap(
tmt,
"lock",
RecordKVFormat::genKey(table_id, 3),
RecordKVFormat::encodeLockCfValue(RecordKVFormat::LockType::Shared, "PK", 3, 20, nullptr, 5));
{
auto iter = region->createCommittedScanner(true, true);
auto lock = iter.getLockInfo({100, nullptr});
ASSERT_EQ(lock, nullptr);
}
region->clearAllData();
}
{
// Test duplicate and tryCompactionFilter
region->insertFromSnap(
Expand Down