{"id":15480,"date":"2025-01-06T11:16:04","date_gmt":"2025-01-06T03:16:04","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=15480"},"modified":"2025-07-02T18:39:40","modified_gmt":"2025-07-02T10:39:40","slug":"kundb%e9%94%81%e7%9b%91%e6%8e%a7%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=15480","title":{"rendered":"kundb\u9501\u76d1\u63a7\u811a\u672c"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\uff0c\u5982\u4f55\u90e8\u7f72\u76d1\u63a7\u811a\u672c\uff0c\u6355\u6349\u4e8b\u52a1\u9501\u4fe1\u606f\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<p>\u6d4b\u8bd5\u73af\u5883\uff1akundb 3.2.2-final <\/p>\n<h4>1.\u90e8\u7f72\u76d1\u63a7\u811a\u672c<\/h4>\n<p>\u4e0a\u4f20\u811a\u672c\u6587\u4ef6 <strong><a href=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/01\/check_long_trx_wait_01.zip\" title=\"check_long_trx_wait_01\">check_long_trx_wait<\/a><\/strong>  \u5e76\u89e3\u538b\uff0c\u4fee\u6539\u8fde\u63a5\u65b9\u5f0f<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2025\/01\/image-1735898929210.png\" alt=\"file\" \/><\/p>\n<p>kundb\u7684\u8fde\u63a5\u65b9\u5f0f\uff0c\u6709\u591a\u79cd\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1a<\/p>\n<pre><code class=\"language-sql\">1.\u5982\u679c\u662f \u76f4\u8fdekungate(\u9ed8\u8ba4\u8fde\u63a5\u5230shard1)\uff0c\u53c2\u8003\u622a\u56fe\n2.\u5982\u679c\u662f \u901a\u8fc7socket\u8fde\u63a5\u5e95\u5c42 shard2\/shard3...\uff0c\u53c2\u8003\uff1a\n<code>mysql_conn=&quot;mysql --socket=\/mnt\/disk5\/kundb1\/shard1\/kundbdata\/mysql.sock&quot;<\/code>\n3.\u5982\u679c\u662f \u8fde\u63a5\u9ad8\u53ef\u7528kundb\uff1a\npasswd='TEwD8*9#Qm!Pd&AG'\nmysql_conn=\"mysql --socket=\/mnt\/disk3\/kundb5\/kundbdata\/mysql.sock -p${passwd}\"<\/code><\/pre>\n<blockquote>\n<p>\u6ce8\u610f\uff1a<br \/>\n1.<code>min_wait_time<\/code> \u9501\u7b49\u5f85\u65f6\u957f\u9608\u503c\uff0c<font color=red>\u53ea\u6709\u8d85\u8fc7\u8be5\u65f6\u95f4\u624d\u4f1a\u88ab\u8bb0\u5f55\u3002\u5982\u679c\u8981\u6392\u67e5\u7684sql\u6267\u884c\u65f6\u957f\u5c11\u4e8e5s\uff0c\u9700\u8981\u964d\u4f4e\u8be5\u9608\u503c<\/font><br \/>\n2.<code>check_time<\/code> \u68c0\u67e5\u6b21\u6570\uff0c\u8bbe\u7f6e\u4e86\u811a\u672c\u8fd0\u884c\u7684\u6b21\u6570\u4e0a\u9650\uff0c\u5982\u679c\u60f3\u8ba9\u7a0b\u5e8f\u4e00\u76f4\u8fd0\u884c\uff0c\u53ef\u4fee\u6539\u811a\u672cwhile\u4e3atrue\u4fdd\u8bc1\u6301\u7eed\u8fd0\u884c\u3002\u540c\u65f6\u9700\u4fdd\u8bc1\u811a\u672c\u8f93\u51fa\u4e0d\u4f1a\u5360\u7528\u8fc7\u591a\u7684\u78c1\u76d8\u7a7a\u95f4\u3002<br \/>\n3.\u5982\u679c\u53ea\u5173\u6ce8\u5bf9\u67d0\u5f20\u8868\u7684\u64cd\u4f5c\uff0c\u53ef\u4ee5\u4fee\u6539\u811a\u672c\uff0c\u5bf9 <code>events_statements_current<\/code> \/ <code>events_statements_history<\/code> \u8868\u505a <code>where lower(sql_text) like &#039;%testtb%&#039;<\/code> \u7684\u8fc7\u6ee4\u3002<\/p>\n<\/blockquote>\n<pre><code class=\"language-shell\">chmod +x check_long_trx_wait.sh\nnohup sh check_long_trx_wait.sh &<\/code><\/pre>\n<p>\u4fdd\u8bc1\u811a\u672c\u540e\u53f0\u8fd0\u884c<\/p>\n<h4>2. \u8fd0\u884c\u6d4b\u8bd5demo<\/h4>\n<p>-session1:<\/p>\n<pre><code class=\"language-sql\">begin \nupdate lkw.testtb set name='zhangsan' where id=1;<\/code><\/pre>\n<p>-session2:<\/p>\n<pre><code class=\"language-sql\">update lkw.testtb set name='lisi' where id=1;<\/code><\/pre>\n<blockquote>\n<p>\u8fd9\u91ccsession2\u4e00\u822c\u4f1a\u6301\u7eed\u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\uff0c\u6700\u7ec8\u62a5\u9519 Lock wait timeout exceeded; try restarting transaction<\/p>\n<\/blockquote>\n<h4>3. \u5206\u6790\u811a\u672c\u8f93\u51fa<\/h4>\n<p>\u89e3\u8bfb\u4e0b long_wait_lock_info_20250106_113018  <a href=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2025\/01\/long_wait_lock_info_20250106_113018.zip\" title=\"long_wait_lock_info_20250106_113018\"><strong>\u3010\u8fd9\u91cc\u8d34\u4e0a\u65e5\u5fd7\u9644\u4ef6\u4f9b\u5927\u5bb6\u53c2\u8003\u3011<\/strong><\/a> \u65e5\u5fd7\u8f93\u51fa\uff0c<\/p>\n<pre><code class=\"language-ruby\">----------------------------------------------------------------------------------------------\n=======================begin check====================\n...\n2025-01-06 11:30:33.483\nREQUESTING_THREAD_ID: 168\nREQUESTING_ENGINE_TRANSACTION_ID:24804\nBLOCKING_THREAD_ID: 126\nBLOCKING_ENGINE_TRANSACTION_ID:24803\n\n# TIMER_WAIT_SECONDS \u4f1a\u6301\u7eed\u589e\u957f\uff0c\u76f4\u81f3\u4e34\u8fd1 innodb_lock_wait_timeout \uff08\u9ed8\u8ba4180\u79d2\uff09\nTIMER_WAIT_SECONDS: 7.0410 REQUESTING_WAIT_SQL: update lkw.testtb set name='lisi' where id=1\n\nOBJECT_SCHEMA: lkw\n  OBJECT_NAME: testtb\n   INDEX_NAME: PRIMARY\n    LOCK_DATA: 1\n\nREQUESTING_PROCESSLIST:\n  PROCESSLIST_ID: 114\nPROCESSLIST_USER: sysdba\nPROCESSLIST_HOST: 172.22.23.1\n\nBLOCK_PROCESSLIST:\n  PROCESSLIST_ID: 72\nPROCESSLIST_USER: sysdba\nPROCESSLIST_HOST: 172.22.23.1\n\n# \u963b\u585e\u8fdb\u7a0b\u7684\u5386\u53f2sql\uff08events_statements_history \u9ed8\u8ba4\u8bb0\u5f55\u6bcf\u4e2a\u7ebf\u7a0b\u6700\u8fd1\u7684\u5341\u6761SQL\u4fe1\u606f\uff0c\u7531\u5168\u5c40\u53c2\u6570performance_schema_events_statements_history_size\u51b3\u5b9a\uff0c\u9ed8\u8ba4\u662f10\u3002\u6240\u4ee5\u68c0\u67e5\u95f4\u9694<code>check_interval<\/code>\u4e3a5\u79d2\u7684\u60c5\u51b5\u4e0b\uff0c\u4e00\u822c\u662f\u53ef\u4ee5\u6355\u6349\u5230sql\u8bed\u53e5\u7684\u3002\uff09\nBLOCKING THREAD HISTORY:\n*************************** 1. row ***************************\n...\n...\n*************************** 7. row ***************************\n          SQL_TEXT: update lkw.testtb set name='zhangsan' where id=1\n          EVENT_ID: 28\n      END_EVENT_ID: 28\nTIMER_WAIT_SECONDS: 0.0213\n LOCK_TIME_SECONDS: 0.0000\n...<\/code><\/pre>\n<p>\u8fd9\u91cc\u80fd\u591f\u770b\u5230\u963b\u585e\u7684\u5177\u4f53sql\u8bed\u53e5\u3002<\/p>\n<p><strong>\u53ef\u4ee5\u90e8\u7f72\u5230\u540e\u53f0\u5b9a\u671f\u6267\u884c\uff0c\u8bb0\u5f97\u5b9a\u671f\u6e05\u7406\u65e5\u5fd7\u8f93\u51fa\u6587\u4ef6<\/strong><\/p>\n<pre><code class=\"language-shell\">#kundb\u957f\u4e8b\u52a1\u76d1\u63a7\u811a\u672c\n#kundb1 shard1 master\n*\/30 * * * * nohup \/bin\/sh \/mnt\/disk5\/kundb1\/shard1\/kundbdata\/check_long_trx_wait_kundb1.sh &\n0 * * * * find \/mnt\/disk5\/kundb1\/shard1\/kundbdata\/long_track_kundb1 -type f -name 'long_wait_lock_info*log' -ctime +7 -exec rm -rf {} \\;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\uff0c\u5982\u4f55\u90e8\u7f72\u76d1\u63a7\u811a\u672c\uff0c\u6355\u6349\u4e8b\u52a1\u9501\u4fe1\u606f\u3002 \u8be6\u7ec6\u8bf4\u660e \u6d4b\u8bd5\u73af\u5883\uff1akundb 3.2.2-fin ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=15480\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-15480","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/15480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15480"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/15480\/revisions"}],"predecessor-version":[{"id":16837,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/15480\/revisions\/16837"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}