Binlog_prewrite_time 很大

  • 【TiDB 版本】:v3.0.9
  • 【问题描述】:偶发性慢查询,通过查看slow_query表的时候为
  Time: 2020-06-01 07:44:00.159650
         Txn_start_ts: 417062881915306181
                 User:
                 Host: 
              Conn_ID: 590035
           Query_time: 4.905505229
           Parse_time: 0.000037627
         Compile_time: 0.00015489
        Prewrite_time: 4.902307495
 Binlog_prewrite_time: 4.902309825
          Commit_time: 0
   Get_commit_ts_time: 0
  Commit_backoff_time: 7.1370000000000005
        Backoff_types: [txnLock
    Resolve_lock_time: 0.000012073
Local_latch_wait_time: 0
           Write_keys: 3
           Write_size: 874
      Prewrite_region: 4
            Txn_retry: 0
         Process_time: 0
            Wait_time: 0
         Backoff_time: 0
        LockKeys_time: 0
        Request_count: 2
           Total_keys: 0
         Process_keys: 0
                   DB:
          Index_names: [tablename:uq_task_id]
          Is_internal: 0
               Digest: ebbf14e061e5ddb64f55ba0409485568349842587632cb235ebdee2f75a97e73
                Stats: tablename:417062881508982869
         Cop_proc_avg: 0
         Cop_proc_p90: 0
         Cop_proc_max: 0
        Cop_proc_addr: 
         Cop_wait_avg: 0
         Cop_wait_p90: 0
         Cop_wait_max: 0
        Cop_wait_addr: 
              Mem_max: 23268
                 Succ: 1
                 Plan: 	IndexLookUp_7  	root	0.013917095401448197
	├─IndexScan_4  	cop 	0.9928382343232485  	table:tablename, index:task_id, range:[504922951218127054,504922951218127054], keep order:false
	└─Selection_6  	cop 	0.013917095401448197	eq(table_name.status, 1)
	  └─TableScan_5	cop 	0.9928382343232485  	table:table_name, keep order:false
          Plan_digest: daf62da201fd6270270faedd17e1a901e71ac3853e4b04ecf10ad4862b790b5b
            Prev_stmt:
                Query: update tablename         set a = 140951, b=2         where                           task_id IN                  (                       1411421
                 )                        and b = b;`

task_id为唯一索引,平时执行很快基本上不到100ms,​请问这种情况一般是什么原因导致的。

  1. 按照诊断地图 https://github.com/pingcap/tidb-map 排查
  2. 上传监控 tikv-trouble-shooting监控 ----> write too slow

一种可能情况: 可以查看,是否 raft rocksdb wal sync duration比较高,是否有比较大的 compaction flow ,有大的value。