SQL语句第一次执行秒级第二次卡死

为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:

【TiDB 版本】4.0

【问题描述】相同的语句第一次执行很快,第二次再执行时就卡死,结果出不来


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

  1. 把具体的例子截个图,哪个版本,可以select tidb_version(); 查看, 是每个sql 都这样,还是某个具体的sql。
  2. 可以反馈下tidb.log 日志

*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0
Edition: Community
Git Commit Hash: 689a6b6439ae7835947fcaccf329a3fc303986cb
Git Branch: heads/refs/tags/v4.0.0
UTC Build Time: 2020-05-28 01:37:40
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false

tidb.log

[2021/03/29 18:19:43.240 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=28] [currIdx=2] [leaderStoreID=7]
[2021/03/29 18:20:14.057 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=28] [currIdx=0] [leaderStoreID=2]
[2021/03/29 18:20:16.214 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:607.18337ms txnStartTS:423890310503333897 region_id:602319 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:16.462 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:302.573701ms txnStartTS:423890310503333897 region_id:542906 store_addr:172.16.24.71:20160"] [conn=30199]
[2021/03/29 18:20:16.666 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:526.002935ms txnStartTS:423890310503333897 region_id:760081 store_addr:172.16.24.71:20160"] [conn=30199]
[2021/03/29 18:20:16.666 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:341.393684ms txnStartTS:423890310503333897 region_id:542906 store_addr:172.16.24.71:20160"] [conn=30199]
[2021/03/29 18:20:17.246 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:331.613843ms txnStartTS:423890310503333897 region_id:760081 store_addr:172.16.24.71:20160"] [conn=30199]
[2021/03/29 18:20:17.361 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:336.93545ms txnStartTS:423890310503333897 region_id:542906 store_addr:172.16.24.71:20160"] [conn=30199]
[2021/03/29 18:20:17.434 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:315.913275ms txnStartTS:423890310503333897 region_id:694394 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:17.737 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:357.196952ms txnStartTS:423890310503333897 region_id:694394 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:17.777 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:338.364882ms txnStartTS:423890310503333897 region_id:694394 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:17.779 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:339.66296ms txnStartTS:423890310503333897 region_id:602444 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:17.781 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:324.15818ms txnStartTS:423890310503333897 region_id:694394 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:17.782 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:325.911546ms txnStartTS:423890310503333897 region_id:602444 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:17.906 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:450.23879ms txnStartTS:423890310503333897 region_id:760081 store_addr:172.16.24.71:20160"] [conn=30199]
[2021/03/29 18:20:18.265 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:339.338619ms txnStartTS:423890310503333897 region_id:119318 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.266 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:346.909736ms txnStartTS:423890310503333897 region_id:694394 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.267 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:341.69153ms txnStartTS:423890310503333897 region_id:694394 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.269 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:343.217752ms txnStartTS:423890310503333897 region_id:602444 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.274 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:320.150077ms txnStartTS:423890310503333897 region_id:119318 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.275 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:355.836911ms txnStartTS:423890310503333897 region_id:119318 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.276 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:356.981239ms txnStartTS:423890310503333897 region_id:602444 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.279 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:354.775803ms txnStartTS:423890310503333897 region_id:602444 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.281 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:356.523938ms txnStartTS:423890310503333897 region_id:694394 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.824 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:324.37435ms txnStartTS:423890310503333897 region_id:119318 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:18.825 +08:00] [INFO] [coprocessor.go:871] ["[TIME_COP_PROCESS] resp_time:303.294567ms txnStartTS:423890310503333897 region_id:119318 store_addr:172.16.24.77:20160"] [conn=30199]
[2021/03/29 18:20:27.379 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30181]
[2021/03/29 18:20:27.380 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30200] [remoteAddr=172.16.24.79:19064]
[2021/03/29 18:20:27.385 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30200] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.385 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30200] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.386 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30182]
[2021/03/29 18:20:27.386 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30201] [remoteAddr=172.16.24.79:19066]
[2021/03/29 18:20:27.387 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30201] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.387 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30201] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.387 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30183]
[2021/03/29 18:20:27.388 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30202] [remoteAddr=172.16.24.79:19068]
[2021/03/29 18:20:27.389 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30202] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.389 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30202] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.389 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30184]
[2021/03/29 18:20:27.390 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30203] [remoteAddr=172.16.24.79:19070]
[2021/03/29 18:20:27.391 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30203] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.391 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30203] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.391 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30185]
[2021/03/29 18:20:27.392 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30204] [remoteAddr=172.16.24.79:19072]
[2021/03/29 18:20:27.392 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30204] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.392 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30204] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.393 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30186]
[2021/03/29 18:20:27.393 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30205] [remoteAddr=172.16.24.79:19074]
[2021/03/29 18:20:27.394 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30205] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.394 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30205] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.395 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30187]
[2021/03/29 18:20:27.395 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30206] [remoteAddr=172.16.24.79:19076]
[2021/03/29 18:20:27.395 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30206] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.396 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30206] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.396 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30188]
[2021/03/29 18:20:27.396 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30207] [remoteAddr=172.16.24.79:19078]
[2021/03/29 18:20:27.397 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30207] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.397 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30207] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.398 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30189]
[2021/03/29 18:20:27.398 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30208] [remoteAddr=172.16.24.79:19080]
[2021/03/29 18:20:27.399 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30208] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.399 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30208] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.399 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30190]
[2021/03/29 18:20:27.400 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30209] [remoteAddr=172.16.24.79:19082]
[2021/03/29 18:20:27.400 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30209] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.401 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30209] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.401 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30191]
[2021/03/29 18:20:27.401 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30210] [remoteAddr=172.16.24.79:19084]
[2021/03/29 18:20:27.402 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30210] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.402 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30210] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.402 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30192]
[2021/03/29 18:20:27.403 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30211] [remoteAddr=172.16.24.79:19086]
[2021/03/29 18:20:27.403 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30211] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.403 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30211] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.404 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30193]
[2021/03/29 18:20:27.404 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30212] [remoteAddr=172.16.24.79:19088]
[2021/03/29 18:20:27.405 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30212] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.405 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30212] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.406 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30194]
[2021/03/29 18:20:27.406 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30213] [remoteAddr=172.16.24.79:19090]
[2021/03/29 18:20:27.406 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30213] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.407 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30213] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.407 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30195]
[2021/03/29 18:20:27.407 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30214] [remoteAddr=172.16.24.79:19092]
[2021/03/29 18:20:27.408 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30214] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.408 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30214] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.409 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30196]
[2021/03/29 18:20:27.409 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30215] [remoteAddr=172.16.24.79:19094]
[2021/03/29 18:20:27.410 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30215] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.410 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30215] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.410 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30197]
[2021/03/29 18:20:27.410 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30216] [remoteAddr=172.16.24.79:19096]
[2021/03/29 18:20:27.411 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30216] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:27.411 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30216] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.411 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30198]
[2021/03/29 18:20:27.412 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30217] [remoteAddr=172.16.24.79:19098]
[2021/03/29 18:20:27.412 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30217] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.412 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30217] [name=tidb_skip_utf8_check] [val=0]
[2021/03/29 18:20:27.413 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30217] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:43.247 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=768650] [currIdx=1] [leaderStoreID=7]
[2021/03/29 18:20:46.240 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=28] [currIdx=1] [leaderStoreID=7]

[2021/03/29 18:20:27.412 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30217] [name=tidb_txn_mode] [val=optimistic]
[2021/03/29 18:20:27.412 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30217] [name=tidb_skip_utf8_check] [val=0]
[2021/03/29 18:20:27.413 +08:00] [INFO] [set.go:207] [“set session var”] [conn=30217] [name=sql_mode] [val=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION]
[2021/03/29 18:20:43.247 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=768650] [currIdx=1] [leaderStoreID=7]
[2021/03/29 18:20:46.240 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=28] [currIdx=1] [leaderStoreID=7]
[2021/03/29 18:21:04.248 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=768650] [currIdx=0] [leaderStoreID=8]
[2021/03/29 18:21:07.244 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=633963] [currIdx=1] [leaderStoreID=9]
[2021/03/29 18:21:10.244 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=633963] [currIdx=0] [leaderStoreID=8]
[2021/03/29 18:21:13.363 +08:00] [INFO] [gc_worker.go:262] ["[gc worker] starts the whole job"] [uuid=5e080ba48f80002] [safePoint=423890168355749888] [concurrency=5]
[2021/03/29 18:21:13.364 +08:00] [INFO] [gc_worker.go:942] ["[gc worker] start resolve locks"] [uuid=5e080ba48f80002] [safePoint=423890168355749888] [concurrency=5]
[2021/03/29 18:21:13.365 +08:00] [INFO] [range_task.go:113] [“range task started”] [name=resolve-locks-runner] [startKey=] [endKey=] [concurrency=5]
[2021/03/29 18:21:14.970 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=28] [currIdx=0] [leaderStoreID=2]
[2021/03/29 18:21:15.630 +08:00] [WARN] [expensivequery.go:167] [expensive_query] [cost_time=60.023455017s] [cop_time=12.743015084s] [process_time=3.136s] [wait_time=0.064s] [request_count=380] [total_keys=2166382] [process_keys=2145908] [num_cop_tasks=380] [process_avg_time=0.008252631s] [process_p90_time=0.021s] [process_max_time=0.04s] [process_max_addr=172.16.24.77:20160] [wait_avg_time=0.000168421s] [wait_p90_time=0.001s] [wait_max_time=0.002s] [wait_max_addr=172.16.24.78:20160] [stats=zs_app_zero_sale_order_item_m:pseudo,zs_dim_pub_dept_lev_all:423890268638937096,s01_dim_shop:pseudo,s01_dim_date_detail:423890268573401096] [conn_id=30199] [user=root] [database=bidb] [table_ids="[22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404,22404]"] [index_names="[zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_SHOPCD,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON,zs_app_zero_sale_order_item_m:I_ZS_APP_ZERO_SALE_ORDER_ITEM_M_STATMON]"] [txn_start_ts=423890310503333897] [mem_max=“62163427 Bytes (59.283663749694824 MB)”] [sql=“select \n t1.STAT_DD,\n ti3.DATE_VARCHAR,\n ti3.MONTH_DES\nfrom (select * from ZS_APP_ZERO_SALE_ORDER_ITEM_M tt\n where tt.STAT_MON >= REPLACE(‘2021-03’, ‘-’, ‘’)\n AND tt.STAT_MON <= REPLACE(‘2021-03’, ‘-’, ‘’)) t1\nLEFT JOIN ZS_DIM_PUB_DEPT_LEV_ALL t2 ON t1.SHOP_CD = t2.ORG_ID_4\nLEFT JOIN S01_DIM_SHOP t ON t1.ERP_SHOP_CD = t.SHOP_CD\nLEFT JOIN S01_DIM_DATE_DETAIL ti3 ON t1.STAT_DD = ti3.DATE_VARCHAR\nwhere ((t.SHOP_TYPE = 1 and t.PHARMACY_MODEL in (1, 2)) or t.CITY_CD is null)\n and t2.CITY_CD not in (-9)\n and t2.BIZ_LINE in (1, 2, 3, 4, 5, 6) \nlimit 2”]
[2021/03/29 18:21:18.066 +08:00] [INFO] [range_task.go:219] [“range task finished”] [name=resolve-locks-runner] [startKey=] [endKey=] [“cost time”=4.701933472s] [“completed regions”=41210]
[2021/03/29 18:21:18.067 +08:00] [INFO] [gc_worker.go:963] ["[gc worker] finish resolve locks"] [uuid=5e080ba48f80002] [safePoint=423890168355749888] [regions=41210]
[2021/03/29 18:21:40.257 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=598627] [currIdx=2] [leaderStoreID=9]
[2021/03/29 18:21:46.240 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=28] [currIdx=1] [leaderStoreID=7]
[2021/03/29 18:22:07.256 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=598627] [currIdx=0] [leaderStoreID=8]
[2021/03/29 18:22:10.257 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=598627] [currIdx=2] [leaderStoreID=7]
[2021/03/29 18:22:13.340 +08:00] [INFO] [gc_worker.go:233] ["[gc worker] there’s already a gc job running, skipped"] [“leaderTick on”=5e080ba48f80002]
[2021/03/29 18:22:16.180 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=28] [currIdx=0] [leaderStoreID=9]
[2021/03/29 18:22:16.467 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=598627] [currIdx=1] [leaderStoreID=8]
[2021/03/29 18:22:28.383 +08:00] [INFO] [server.go:388] [“new connection”] [conn=30218] [remoteAddr=172.16.8.124:29582]
[2021/03/29 18:22:28.388 +08:00] [INFO] [server.go:391] [“connection closed”] [conn=30218]
[2021/03/29 18:22:40.261 +08:00] [INFO] [region_cache.go:772] [“switch region leader to specific leader due to kv return NotLeader”] [regionID=598627] [currIdx=2] [leaderStoreID=7]

  1. 请问这个是正式环境还是测试环境? 能否升级到最新版本试试?
  2. 可以查看over-view 监控,这个tidb-server的资源内存,cpu使用情况。
  3. 查看 tidb stderr log 是否有对应的panic 信息。

如果第一次就执行不出来可以和资源内存相关,第一次执行出来了,再执行出现的问题,整个库就只执行这一条语句。tidb_stderr.log没有相关信息!!!!!!

  1. 如果这个sql占用资源很多,第一次执行完以后,没有释放,有可能导致第二次执行时资源不足,所以说看一
    下。
  2. 查看 github 也有类似问题, https://github.com/pingcap/tidb/issues/20779
  3. 如果是测试环境,每个版本已经修复了很多问题。如果可以的话,请尝试新版本,目前是v4.0.11。并且日志和监控也更加方便定位问题。