TiKV 报错

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。

  • 【TiDB 版本】:3.0.2
  • 【问题描述】:TiKV 报错如下

[2019/11/19 07:12:48.028 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”] [2019/11/19 07:12:48.067 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”] [2019/11/19 07:12:48.105 +00:00] [INFO] [tracker.rs:150] [slow-query] [internal_key_skipped_count=430147] [internal_delete_skipped_count=0] [block_cache_hit_count=1513] [block_read_count=0] [block_read_byte=0] [scan_first_range=“Some(start: 7480000000000352F75F7280000000000C7F55 end: 7480000000000352F75F7280000000000FC777)”] [scan_ranges=1] [scan_iter_processed=430148] [scan_iter_ops=430150] [scan_is_desc=false] [tag=select] [table_id=217847] [txn_start_ts=412653333471821827] [wait_time=22.218s] [total_process_time=3.005s] [peer_id=ipv4:172.31.42.102:43406] [region_id=2892968] [2019/11/19 07:12:48.116 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”] [2019/11/19 07:12:48.150 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”] [2019/11/19 07:12:48.188 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”] [2019/11/19 07:12:48.223 +00:00] [INFO] [peer.rs:1336] [“starts destroy”] [merged_by_target=false] [peer_id=2209915] [region_id=1721753] [2019/11/19 07:12:48.223 +00:00] [INFO] [apply.rs:2789] [“target region is not found, drop messages”] [region_id=1721753] [2019/11/19 07:12:48.223 +00:00] [INFO] [peer.rs:524] [“begin to destroy”] [peer_id=2209915] [region_id=1721753] [2019/11/19 07:12:48.223 +00:00] [INFO] [pd.rs:628] [“remove peer statistic record in pd”] [region_id=1721753] [2019/11/19 07:12:48.243 +00:00] [INFO] [peer_storage.rs:1325] [“finish clear peer meta”] [takes=19.002642ms] [raft_logs=25] [raft_key=1] [apply_key=1] [meta_key=1] [region_id=1721753] [2019/11/19 07:12:48.252 +00:00] [INFO] [peer.rs:571] [“peer destroy itself”] [takes=26.834163ms] [peer_id=2209915] [region_id=1721753] [2019/11/19 07:12:48.252 +00:00] [INFO] [router.rs:446] ["[region 1721753] shutdown mailbox"] [2019/11/19 07:12:48.252 +00:00] [INFO] [region.rs:451] [“register deleting data in range”] [end_key=7A74800000000002F4FF655F698000000000FF0000010380000000FF5D663CB403800000FF0000000001038000FF000000044DAE0380FF000000000000A403FF800000000352FC35FF0000000000000000F7] [start_key=7A74800000000002F4FF655F698000000000FF0000010380000000FF5D647AB403800000FF0000000001038000FF00000001A6E70380FF000000000000A403FF800000000343E76EFF0000000000000000F7] [region_id=1721753] [2019/11/19 07:12:48.255 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”] [2019/11/19 07:12:48.262 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB405F69800000000000000103800000005DD384E00380000000000AEE9E03800000000000055C03800000000003A3F1 lock_version: 412653228011290629 key: 74800000000004BB405F72800000000003A6F1 lock_ttl: 12394 txn_size: 41”] [2019/11/19 07:12:48.294 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”] [2019/11/19 07:12:48.324 +00:00] [INFO] [tracker.rs:150] [slow-query] [internal_key_skipped_count=430147] [internal_delete_skipped_count=0] [block_cache_hit_count=1513] [block_read_count=0] [block_read_byte=0] [scan_first_range=“Some(start: 7480000000000352F75F7280000000000C7F55 end: 7480000000000352F75F7280000000000FC777)”] [scan_ranges=1] [scan_iter_processed=430148] [scan_iter_ops=430150] [scan_is_desc=false] [tag=select] [table_id=217847] [txn_start_ts=412653332986855427] [wait_time=24.497s] [total_process_time=2.775s] [peer_id=ipv4:172.31.42.102:43390] [region_id=2892968] [2019/11/19 07:12:48.358 +00:00] [ERROR] [endpoint.rs:454] [error-response] [err=“locked primary_lock: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A493 lock_version: 412653235941146632 key: 74800000000004BB925F69800000000000000103800000005DD391C4038000000000005C4903800000000000001303800000000000A494 lock_ttl: 3001 txn_size: 342”]

若提问为性能优化、故障排查类问题,请下载脚本运行。全选终端打印结果,并复制粘贴上传。

更新时发现主键冲突,也就是说 当一个事务去更新的时候,发现有一个事务正在更新,该问题是业务设计逻辑问题。需要从业务层去修改。

根据报错的 key 信息去解析表 (table_id,上述 key 的 table_id 为 310162 )(https://github.com/disksing/mok ),根据 curl http://{TiDBIP}:10080/schema?table_id=${table_id} 或者去数据库里查询来获取对应的表名: select TABLE_NAME,TIDB_TABLE_ID from information_schema.tables; 根据表名来进一步定位出现异常的 SQL 信息来分析。

1赞