如何确认是哪种原因
需要看系统表。
查看慢 SQL
select *
from information_schema.slow_query
where query like ‘%point_get%’
order by time desc
limit 10;
关注:
Write Conflict
Lock wait
Backoff
TxnRetry
查看事务重试
select *
from information_schema.cluster_tidb_trx;
看:
waiting_start_time
state
查看锁
select *
from information_schema.data_lock_waits;
可以看到:
谁在等锁
谁持有锁
这是最关键的。
查看冲突
select *
from information_schema.cluster_tidb_trx;
关注:
retry_count
六、日志中会出现
TiDB 日志:
txn retry
write conflict
lock wait
backoff
例如:
txnRetry
backoff: tikvLockFast
或
Write conflict
这就能确认。