TiDB suddenly cannot connect

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb突然连接不上

| username: TiDBer_vZIeuSNY

【TiDB Usage Environment】Production Environment
【TiDB Version】
【Encountered Problem: Problem Phenomenon and Impact】
TiDB suddenly cannot connect. Checking the logs, it is found that the TiDB component keeps reporting “lock txn not found, lock has expired”.

| username: zhanggame1 | Original post link

First, stop the application from accessing the database and observe.

The official documentation describes the TxnLockNotFound error as occurring because the transaction was committed too slowly, exceeding the TTL time. When attempting to commit, it was found that it had been rolled back by another transaction. When TiDB automatic transaction retry is enabled, the transaction will automatically retry in the background (note the difference between explicit and implicit transactions).

Handling TiDB Lock Conflicts | PingCAP Documentation Center

| username: TiDBer_vZIeuSNY | Original post link

According to the key, the tables where the transaction errors occurred are stats_meta and stats_buckets. At that time, there was indeed a statement analyze table dy_live_adv_rt_qc_incre; that was running continuously. Why is this happening?


| username: yulei7633 | Original post link

This is the collection of statistical information.

| username: 像风一样的男子 | Original post link

Check the dashboard for any anomalies in latency, QPS, CPU, memory, and slow queries.

| username: TiDBer_vZIeuSNY | Original post link

The latency, QPS, CPU, memory, and slow queries in the dashboard all seem normal. Could the experts please help analyze further? Thank you.

| username: 像风一样的男子 | Original post link

Run admin show ddl jobs to check if there are any stuck DDL operations.

| username: TiDBer_vZIeuSNY | Original post link

“admin show ddl jobs” to check if there are any stuck DDLs.
Confirmed, there are none.

| username: liuis | Original post link

admin show ddl jobs