Skip to content

Commit

Permalink
Compatible new field in write/lock cf with TiKV (#7214) (#7217)
Browse files Browse the repository at this point in the history
close #7212
  • Loading branch information
ti-chi-bot authored Apr 4, 2023
1 parent df59528 commit 4011355
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dbms/src/Storages/Transaction/RegionCFDataBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ inline void decodeLockCfValue(DecodedLockCFValue & res)
UNUSED(versions_to_last_change);
break;
}
case TXN_SOURCE_PREFIX_FOR_LOCK:
{
// Used for CDC, useless for TiFlash.
UInt64 txn_source_prefic = readVarUInt(data, len);
UNUSED(txn_source_prefic);
break;
}
default:
{
std::string msg = std::string("invalid flag ") + flag + " in lock value " + value.toDebugString();
Expand Down
18 changes: 18 additions & 0 deletions dbms/src/Storages/Transaction/TiKVRecordFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ static const char ROLLBACK_TS_PREFIX = 'r';
static const char FLAG_OVERLAPPED_ROLLBACK = 'R';
static const char GC_FENCE_PREFIX = 'F';
static const char LAST_CHANGE_PREFIX = 'l';
static const char TXN_SOURCE_PREFIX_FOR_WRITE = 'S';
static const char TXN_SOURCE_PREFIX_FOR_LOCK = 's';

static const size_t SHORT_VALUE_MAX_LEN = 64;

Expand Down Expand Up @@ -419,6 +421,22 @@ inline DecodedWriteCFValue decodeWriteCfValue(const TiKVValue & value)
* rewriting record and there must be a complete row written to tikv, just ignore it in tiflash.
*/
return std::nullopt;
case RecordKVFormat::LAST_CHANGE_PREFIX:
{
// Used to accelerate TiKV MVCC scan, useless for TiFlash.
UInt64 last_change_ts = readUInt64(data, len);
UInt64 versions_to_last_change = readVarUInt(data, len);
UNUSED(last_change_ts);
UNUSED(versions_to_last_change);
break;
}
case RecordKVFormat::TXN_SOURCE_PREFIX_FOR_WRITE:
{
// Used for CDC, useless for TiFlash.
UInt64 txn_source_prefic = readVarUInt(data, len);
UNUSED(txn_source_prefic);
break;
}
default:
throw Exception("invalid flag " + std::to_string(flag) + " in write cf", ErrorCodes::LOGICAL_ERROR);
}
Expand Down

0 comments on commit 4011355

Please sign in to comment.