Skip to content

Commit

Permalink
[FLASH-781] Support Pessimistic When Resolving Lock (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
solotzg authored Dec 24, 2019
1 parent 4778610 commit 655e020
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dbms/src/Storages/Transaction/RegionData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,17 @@ RegionDataReadInfo RegionData::readDataByWriteIt(const ConstWriteCFIter & write_
throw Exception(" key [" + key->toString() + "] not found in data cf", ErrorCodes::LOGICAL_ERROR);
}

// https://github.com/tikv/tikv/blob/master/components/txn_types/src/lock.rs#L179-L203
LockInfoPtr RegionData::getLockInfo(Timestamp start_ts) const
{
enum LockType : UInt8
{
Put = 'P',
Delete = 'D',
Lock = 'L',
Pessimistic = 'S',
};

for (const auto & [handle, value] : lock_cf.getData())
{
std::ignore = handle;
Expand All @@ -118,9 +127,8 @@ LockInfoPtr RegionData::getLockInfo(Timestamp start_ts) const
const auto & [lock_type, primary, ts, ttl, data] = decoded_val;
std::ignore = tikv_val;
std::ignore = data;
std::ignore = lock_type;

if (ts > start_ts)
if (ts > start_ts || lock_type == Lock || lock_type == Pessimistic)
continue;

return std::make_unique<LockInfo>(LockInfo{primary, ts, RecordKVFormat::decodeTiKVKey(*tikv_key), ttl});
Expand Down

0 comments on commit 655e020

Please sign in to comment.