Skip to content

Commit

Permalink
KVStore: Record bypass lock in resolve lock (#8883)
Browse files Browse the repository at this point in the history
ref #8864
  • Loading branch information
CalvinNeo authored Apr 3, 2024
1 parent f04b16d commit 49a1529
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ static_assert(RAFT_REGION_BIG_WRITE_THRES * 4 < RAFT_REGION_BIG_WRITE_MAX, "Inva
M(tiflash_raft_read_index_events_count, \
"Raft read index events counter", \
Counter, \
F(type_bypass_lock, {{"type", "bypass_lock"}}), \
F(type_use_histroy, {{"type", "use_histroy"}}), \
F(type_use_cache, {{"type", "use_cache"}})) \
M(tiflash_raft_learner_read_failures_count, \
Expand Down
1 change: 1 addition & 0 deletions dbms/src/Storages/KVStore/FFI/ProxyFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ inline EngineStoreServerHelper GetEngineStoreServerHelper(EngineStoreServerWrap
.fn_set_pb_msg_by_bytes = SetPBMsByBytes,
.fn_handle_safe_ts_update = HandleSafeTSUpdate,
.fn_fast_add_peer = FastAddPeer,
.fn_get_lock_by_key = GetLockByKey,
.fn_query_fap_snapshot_state = QueryFapSnapshotState,
.fn_clear_fap_snapshot = ClearFapSnapshot,
.fn_kvstore_region_exists = KvstoreRegionExists,
Expand Down
11 changes: 9 additions & 2 deletions dbms/src/Storages/KVStore/MultiRaft/RegionData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <Common/TiFlashMetrics.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <Storages/KVStore/FFI/ColumnFamily.h>
Expand Down Expand Up @@ -228,8 +229,14 @@ DecodedLockCFValuePtr RegionData::getLockInfo(const RegionLockReadQuery & query)
continue;
if (lock_info.min_commit_ts > query.read_tso)
continue;
if (query.bypass_lock_ts && query.bypass_lock_ts->count(lock_info.lock_version))
continue;
if (query.bypass_lock_ts)
{
if (query.bypass_lock_ts->count(lock_info.lock_version))
{
GET_METRIC(tiflash_raft_read_index_events_count, type_bypass_lock).Increment();
continue;
}
}
return lock_info_ptr;
}

Expand Down
5 changes: 3 additions & 2 deletions dbms/src/Storages/KVStore/Region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ std::string Region::getDebugString() const
{
const auto & meta_snap = meta.dumpRegionMetaSnapshot();
return fmt::format(
"[region_id={} index={} table_id={} ver={} conf_ver={} state={} peer={}]",
"[region_id={} index={} table_id={} ver={} conf_ver={} state={} peer={} range={}]",
id(),
meta.appliedIndex(),
mapped_table_id,
meta_snap.ver,
meta_snap.conf_ver,
raft_serverpb::PeerState_Name(peerState()),
meta_snap.peer.ShortDebugString());
meta_snap.peer.ShortDebugString(),
getRange()->toDebugString());
}

std::string Region::toString(bool dump_status) const
Expand Down

0 comments on commit 49a1529

Please sign in to comment.