{"id":10974,"date":"2024-03-31T19:51:10","date_gmt":"2024-03-31T11:51:10","guid":{"rendered":"https:\/\/www.orczhou.com\/?p=10974"},"modified":"2024-03-31T19:52:38","modified_gmt":"2024-03-31T11:52:38","slug":"using-hook-for-sysbench-error-duplicate-entry","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2024\/03\/using-hook-for-sysbench-error-duplicate-entry\/","title":{"rendered":"\u4f7f\u7528hook\u89e3\u51b3Sysbench\u538b\u6d4bMySQL\u9047\u5230\u7684&#8221;Duplicate entry&#8221;\u95ee\u9898"},"content":{"rendered":"\n\n\n\n<p>\u4ece<a href=\"https:\/\/archive.fosdem.org\/2017\/schedule\/event\/sysbench\/attachments\/slides\/1519\/export\/events\/attachments\/sysbench\/slides\/1519\/sysbench.pdf\">\u4e00\u4e2aSlide\u4ecb\u7ecd\u4e2d<\/a>\uff0c\u5728Sysbench\u6d4b\u8bd5\u4e2d\u53ef\u4ee5\u901a\u8fc7hook\u7684\u65b9\u5f0f\u5bf9\u4e00\u4e9bMySQL\u62a5\u9519\u8fdb\u884c\u6355\u83b7\uff0c\u4ee5\u907f\u514d\u6d4b\u8bd5\u4e2d\u65ad\u3002\u4f46\u662f\u505a\u4e86\u4e00\u4e9b\u641c\u7d22\uff0c\u5bf9\u8be5\u80fd\u529b\u5e76\u6ca1\u6709\u6587\u6863\u63cf\u8ff0\uff0c\u6545\u505a\u4e86\u4e00\u4e9b\u6d4b\u8bd5\uff0c\u4ee5\u9a8c\u8bc1\u8be5\u80fd\u529b\u3002<\/p>\n\n\n\n<p>\u5728\u524d\u9762\u7684\u6587\u7ae0\u201c<a href=\"https:\/\/www.orczhou.com\/index.php\/2024\/03\/sysbench-duplicate-entry-key\/\" data-type=\"link\" data-id=\"https:\/\/www.orczhou.com\/index.php\/2024\/03\/sysbench-duplicate-entry-key\/\">Sysbench\u538b\u6d4bMySQL\u4e2d\u9047\u5230\u7684\u201dDuplicate entry\u201d\u95ee\u9898<\/a>\u201d\u4e2d\uff0c\u8f83\u4e3a\u8be6\u7ec6\u7684\u5206\u6790\u4e86\u5728\u4f7f\u7528\u4e86<code>--skip_trx=on<\/code>\u540e \uff0cSysbench\uff08\u7248\u672c1.0.20\uff09\u5728\u6d4b\u8bd5\u4e2d\u9047\u5230\u7684&#8221;Duplicate entry&#8221;\u95ee\u9898\u3002\u4e5f\u63d0\u5230\u4e86\uff0c\u53ef\u4ee5\u5728\u811a\u672c\u4e2d\u6dfb\u52a0hook\u7684\u65b9\u5f0f\u89e3\u51b3\uff0c\u4e0d\u8fc7\u4e4b\u524d\u5e76\u6ca1\u6709\u5bf9\u8fd9\u4e2a\u65b9\u6848\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<p>\u5728\u6d4b\u8bd5\u811a\u672c\u4e2d\u4f7f\u7528hook\u7684\u65b9\u6848\uff0c\u5728sysbench\u7684\u6587\u6863\u4e2d\u5e76\u6ca1\u6709\u627e\u5230\u8be6\u7ec6\u7684\u8bf4\u660e\uff0c\u8fd9\u91cc\u5c06\u5bf9\u8fd9\u4e2a\u65b9\u6848\u505a\u4e00\u4e2a\u4f7f\u7528\u8bf4\u660e\uff0c\u5e76\u9a8c\u8bc1\u5176\u6709\u6548\u6027\u3002\u6211\u4eec\u5c06\u5206\u4e24\u7ec4\u5bf9\u6bd4\u6d4b\u8bd5\uff0c\u9a8c\u8bc1\u65b0\u589ehook\u7684\u6709\u6548\u6027\uff0c\u4ee5\u53ca\u65b0\u589ehook\u540e\uff0c\u5bf9\u6d4b\u8bd5\u7ed3\u679c\u662f\u5426\u5bf9\u6027\u80fd\u6709\u5f71\u54cd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6d4b\u8bd5\u7ed3\u679c\u6982\u8ff0<\/h3>\n\n\n\n<p>Sysbench\u7684\u8be5\u80fd\u529b\u5e76\u6ca1\u6709\u5728\u6587\u6863\u4e2d\u627e\u5230\u8bf4\u660e\uff0c\u53ea\u662f\u5728\u4e00\u4e2aSlide\u4e2d\u770b\u5230\u7684\u3002\u672c\u6587\u7684\u6d4b\u8bd5\u9a8c\u8bc1\u4e86\u5982\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5728\u6d4b\u8bd5lua\u811a\u672c\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528hook\u6709\u6548\u7684\u907f\u514d\u201dDuplicate entry\u201d\u7b49\u62a5\u9519\u5e26\u6765\u7684\u6d4b\u8bd5\u4e2d\u65ad\u95ee\u9898<\/li>\n\n\n\n<li>\u4f7f\u7528\u4e86hook\u4e4b\u540e\uff0c\u6d4b\u8bd5\u524d\u540e\u6027\u80fd\u5e76\u6ca1\u6709\u89c2\u6d4b\u5230\u5dee\u5f02\uff08\u53ef\u4ee5\u8ba4\u4e3a\uff0c\u4e00\u822c\u6765\u8bf4\uff0c\u53d1\u751f\u9519\u8bef\u7684\u60c5\u51b5\u5e76\u4e0d\u591a\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u6240\u4ee5\uff0c\u540e\u7eed\u6d4b\u8bd5\u4e2d\uff0c\u5982\u679c\u4e0d\u53ef\u907f\u514d\u7684\u4f1a\u9047\u5230\u201dDuplicate entry\u201d\u62a5\u9519\uff08\u6216\u5176\u4ed6\u62a5\u9519\uff09\u65f6\uff0c\u5c06\u4f7f\u7528hook\u7684\u65b9\u5f0f\u6765\u907f\u514d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5982\u4f55\u4fee\u6539\u6d4b\u8bd5\u811a\u672c<\/h3>\n\n\n\n<p>\u5177\u4f53\u7684\uff0c\u6211\u4eec\u5728\u539f\u6765\u7684oltp_read_write\uff08sysbench 1.0.20\u7248\u672c\uff09\u811a\u672c\u4e2d\u65b0\u589e\u5982\u4e0b\u4ee3\u7801\u7247\u6bb5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"c\" class=\"language-c\">function sysbench.hooks.sql_error_ignorable(err)\n  if err.sql_errno == 1062 then -- ER_DUP_ENTRY\n    -- do nothing\n    return true\n  end\nend<\/code><\/pre>\n\n\n\n<p>\u5b8c\u6574\u7684\u4ee3\u7801\u53ef\u4ee5\u53c2\u8003\uff1a<a href=\"https:\/\/github.com\/orczhou\/myscripts\/blob\/main\/oltp_read_write_with_hooks.lua\">oltp_read_write_with_hooks.lua<\/a><\/p>\n\n\n\n<p>\u5177\u4f53\u7684diff\u6587\u4ef6\u53c2\u8003\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"c\" class=\"language-c\">--- \/usr\/share\/sysbench\/oltp_read_write.lua\n+++ oltp_read_write_with_hooks.lua\n@@ -21,6 +21,13 @@\n\n require(\"oltp_common\")\n\n+function sysbench.hooks.sql_error_ignorable(err)\n+  if err.sql_errno == 1062 then -- ER_DUP_ENTRY\n+    -- do nothing\n+    return true\n+  end\n+end\n+\n function prepare_statements()\n    if not sysbench.opt.skip_trx then\n       prepare_begin()<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6d4b\u8bd5\u8bf4\u660e<\/h3>\n\n\n\n<p>\u8fd9\u91cc\u4f9d\u65e7\u4f7f\u7528oltp_read_write\u8d1f\u8f7d\u8fdb\u884c\u6d4b\u8bd5\uff0c\u6d4b\u8bd5\u65f6\u4f7f\u7528\u4e86\u53c2\u6570 <code>--skip_trx=on --db-ps-mode=disable --rand-type=uniform<\/code> \uff0c\u5176\u4e2d\u53c2\u6570<code>--skip_trx=on<\/code>\u4f1a\u5e26\u6765\u201dDuplicate entry\u201d\u62a5\u9519\uff0c\u5e76\u5bfc\u81f4\u6d4b\u8bd5\u88ab\u7ec8\u6b62\uff08\u8be6\u7ec6\u539f\u56e0\u5206\u6790\u53c2\u8003\uff1a<a href=\"https:\/\/www.orczhou.com\/index.php\/2024\/03\/sysbench-duplicate-entry-key\/\">Sysbench\u538b\u6d4bMySQL\u4e2d\u9047\u5230\u7684\u201dDuplicate entry\u201d\u95ee\u9898<\/a>\uff09\u3002\u6d4b\u8bd5\u5206\u4e24\u7ec4\uff0c\u4e00\u7ec4\u662f\u4f7f\u7528\u539f\u59cb\u7684oltp_read_write\u811a\u672c\u8fdb\u884c\u6d4b\u8bd5\uff1b\u53e6\u4e00\u7ec4\uff0c\u5219\u5728\u811a\u672c\u4e2d\u65b0\u589e\u4e0a\u8ff0hook\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>\u800c\u540e\u89c2\u6d4b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u4e86hook\u540e\uff0csysbench\u662f\u5426\u8fd8\u4f1a\u56e0\u4e3a\u201dDuplicate entry\u201d\u88ab\u7ec8\u6b62\uff1b<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">nohup .\/sysbench_auto.sh -l .\/oltp_read_write_with_hook.lua -hYOUR_HOST -uYOUR_USERNAME -pYOUR_PASSWORD &gt; sysbench_with_hook_with_skip.log 2&gt;&amp;1 &amp;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528hook\uff0c\u4e0e\u4e0d\u4f7f\u7528hook\uff0c\u5bf9\u6d4b\u8bd5\u7ed3\u679c\u662f\u5426\u6709\u5f71\u54cd\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">nohup .\/sysbench_auto.sh -hYOUR_HOST -uYOUR_USERNAME -pYOUR_PASSWORD &gt; sysbench_no_hook_with_skip.log 2&gt;&amp;1 &amp;<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u7684sysbench_auto.sh\u662f\u4e00\u4e2a\u81ea\u5df1\u7f16\u5199\u7684\u81ea\u52a8\u5316\u7684sysbench\u6d4b\u8bd5\u811a\u672c\u3002\u4f1a\u81ea\u52a8\u5316\u7684\u3001\u987a\u5e8f\u7684\u8fdb\u884c\u591a\u4e2a\u4e0d\u540c\u5e76\u53d1\u4e0b\u7684\u6027\u80fd\u6d4b\u8bd5\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6d4b\u8bd5\u7ed3\u679c\u8be6\u60c5<\/h3>\n\n\n\n<p><strong>\u6ca1\u6709\u4f7f\u7528hook\u7684\u6d4b\u8bd5\u4e2d<\/strong>\uff0c\u6ce8\u610f\u5230\uff0c\u5728\u5e76\u53d1\u5ea6\u4e3a48\u300196\u3001128\u3001192\u65f6\u5019\uff0c\u6d4b\u8bd5\u88ab\u7ec8\u6b62\uff0c\u800c\u89c2\u6d4b\u65e5\u5fd7\u4e5f\u770b\u5230\u4e86\u662f\u56e0\u4e3a\u201cDuplicate entry\u201d\u6240\u5bfc\u81f4\u7684\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">threads|transactions| queries| time |avg\/Latency|95%\/Latency\n      4|       20311|  365598|300.05|      59.09|      66.84\n      8|       38195|  687510|300.04|      62.84|      71.83\n     16|       71296| 1283328|300.07|      67.33|      77.19\n     24|      101911| 1834398|300.05|      70.65|      81.48\n     32|      131859| 2373462|300.06|      72.81|      84.47\n     48|           0|       0|  0.00|       0.00|       0.00\n     64|      233840| 4209120|300.09|      82.12|     101.13\n     96|           0|       0|  0.00|       0.00|       0.00\n    128|           0|       0|  0.00|       0.00|       0.00\n    192|           0|       0|  0.00|       0.00|       0.00<\/code><\/pre>\n\n\n\n<p>\u5177\u4f53\u62a5\u9519\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">FATAL: mysql_drv_query() returned error 1062 (Duplicate entry '876663' for key 'sbtest3.PRIMARY') for query<\/code><\/pre>\n\n\n\n<p>\u5728\u4f7f\u7528\u4e86hook\u7684\u6d4b\u8bd5\u4e2d\uff0c\u6ce8\u610f\u5230\uff0c\u6d4b\u8bd5\u987a\u5229\u7684\u5b8c\u6210\u4e86\uff0c<strong>\u5e76\u6ca1\u6709\u88ab\u7ec8\u6b62<\/strong>\uff0c\u800c\u89c2\u5bdf\u65e5\u5fd7\uff0c\u4e5f\u53ef\u4ee5\u770b\u5230\uff0c\u671f\u95f4\u4e5f\u662f\u9047\u5230\u4e86Duplicate entry\u62a5\u9519\u7684\uff0c\u4f46\u56e0\u4e3ahook\u7684\u5904\u7406\uff0c\u6d4b\u8bd5\u5e76\u6ca1\u6709\u7ec8\u6b62\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">threads|transactions| queries| time |avg\/Latency|95%\/Latency\n      4|       19547|  351846|300.06|      61.40|      71.83\n      8|       37524|  675432|300.06|      63.97|      74.46\n     16|       70847| 1275246|300.05|      67.76|      78.60\n     24|      102541| 1845738|300.06|      70.22|      81.48\n     32|      132424| 2383632|300.07|      72.50|      86.00\n     48|      187065| 3367170|300.06|      76.98|      92.42\n     64|      234717| 4224923|300.07|      81.81|      99.33\n     96|      308744| 5557409|300.06|      93.28|     118.92\n    128|      341177| 6141186|300.09|     112.57|     147.61\n    192|      364561| 6562115|300.10|     158.03|     211.60<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e24\u7ec4\u6d4b\u8bd5\u6027\u80fd\u7684\u5bf9\u6bd4<\/h4>\n\n\n\n<p>\u6839\u636e\u5982\u4e0a\u6027\u80fd\u6d4b\u8bd5\u6570\u636e\uff0c\u5bf9QPS\uff08Queries Per Second\uff09\u8fdb\u884c\u5bf9\u6bd4\uff1a<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"472\" src=\"https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-3.png\" alt=\"\" class=\"wp-image-11010\" style=\"width:478px;height:auto\" srcset=\"https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-3.png 808w, https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-3-300x175.png 300w, https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-3-768x449.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/figure>\n\n\n\n<p><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"741\" src=\"https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-5-1024x741.png\" alt=\"\" class=\"wp-image-11013\" style=\"width:398px;height:auto\" srcset=\"https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-5-1024x741.png 1024w, https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-5-300x217.png 300w, https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-5-768x555.png 768w, https:\/\/www.orczhou.com\/wp-content\/uploads\/2024\/03\/image-5.png 1402w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u6574\u4f53\u6027\u80fd\u6ce2\u52a8\u975e\u5e38\u5c0f\uff0c\u4f18\u52bf\u5728\u8f83\u9ad8\u5e76\u53d1\u65f6\uff0c\u6027\u80fd\u5dee\u5f02\u90fd\u5c0f\u4e8e1%\uff1b\u4ece\u8d8b\u52bf\u56fe\u4e0a\u4e5f\u80fd\u591f\u770b\u51fa\u6765\uff0c\u4e24\u8005\u51e0\u4e4e\u662f\u91cd\u5408\u7684\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u66f4\u591a\u6d4b\u8bd5\u539f\u59cb\u6570\u636e<\/h4>\n\n\n<div><h5>2024-03-26@Benchmark on sysbench with or without hook<\/h5>\n<pre style=\"font-size:0.6em;\">host : rds_m6i_xlarge_no_hook_with_skip \nsub_dir : rds_m6i_xlarge_no_hook_with_skip \nins_code : m6i.xlarge \nha_type : ha \nregion : tokyo \nstorage_size : 100 \niops : 3000 \n<\/pre><pre style=\"font-size:0.6em;\">sysbench for host :multiaz.cjzowaj9vqpd.ap-northeast-1.rds.amazonaws.com\nthreads|transactions| queries| time |avg\/Latency|95%\/Latency\n      4|       20311|  365598|300.05|      59.09|      66.84 \n      8|       38195|  687510|300.04|      62.84|      71.83 \n     16|       71296| 1283328|300.07|      67.33|      77.19 \n     24|      101911| 1834398|300.05|      70.65|      81.48 \n     32|      131859| 2373462|300.06|      72.81|      84.47 \n     48|           0|       0|  0.00|       0.00|       0.00 \n     64|      233840| 4209120|300.09|      82.12|     101.13 \n     96|           0|       0|  0.00|       0.00|       0.00 \n    128|           0|       0|  0.00|       0.00|       0.00 \n    192|           0|       0|  0.00|       0.00|       0.00 \n<\/pre><pre style=\"font-size:0.6em;\">host : rds_m6i_xlarge_with_hook_with_skip \nsub_dir : rds_m6i_xlarge_with_hook_with_skip \nins_code : m6i.xlarge \nha_type : ha \nregion : tokyo \nstorage_size : 100 \niops : 3000 \n<\/pre><pre style=\"font-size:0.6em;\">sysbench for host :multiaz.cjzowaj9vqpd.ap-northeast-1.rds.amazonaws.com\nthreads|transactions| queries| time |avg\/Latency|95%\/Latency\n      4|       19547|  351846|300.06|      61.40|      71.83 \n      8|       37524|  675432|300.06|      63.97|      74.46 \n     16|       70847| 1275246|300.05|      67.76|      78.60 \n     24|      102541| 1845738|300.06|      70.22|      81.48 \n     32|      132424| 2383632|300.07|      72.50|      86.00 \n     48|      187065| 3367170|300.06|      76.98|      92.42 \n     64|      234717| 4224923|300.07|      81.81|      99.33 \n     96|      308744| 5557409|300.06|      93.28|     118.92 \n    128|      341177| 6141186|300.09|     112.57|     147.61 \n    192|      364561| 6562115|300.10|     158.03|     211.60 \n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u4e00\u4e2aSlide\u4ecb\u7ecd\u4e2d\uff0c\u5728Sysbench\u6d4b\u8bd5\u4e2d\u53ef\u4ee5\u901a\u8fc7hook\u7684\u65b9\u5f0f\u5bf9\u4e00\u4e9bMySQL\u62a5\u9519\u8fdb\u884c\u6355\u83b7\uff0c\u4ee5\u907f\u514d\u6d4b\u8bd5\u4e2d\u65ad\u3002\u4f46\u662f\u505a\u4e86\u4e00\u4e9b\u641c\u7d22\uff0c\u5bf9\u8be5\u80fd\u529b\u5e76\u6ca1\u6709\u6587\u6863\u63cf\u8ff0\uff0c\u6545\u505a\u4e86\u4e00\u4e9b\u6d4b\u8bd5\uff0c\u4ee5\u9a8c\u8bc1\u8be5\u80fd\u529b\u3002 \u5728\u524d\u9762\u7684\u6587\u7ae0\u201cSysbench\u538b\u6d4bMySQL\u4e2d\u9047\u5230\u7684\u201dDuplicate entry\u201d\u95ee\u9898\u201d\u4e2d\uff0c\u8f83\u4e3a\u8be6\u7ec6\u7684\u5206\u6790\u4e86\u5728\u4f7f\u7528\u4e86&#8211;skip_trx=on\u540e \uff0cSysbench\uff08\u7248\u672c1.0.20\uff09\u5728\u6d4b\u8bd5\u4e2d\u9047\u5230\u7684&#8221;Duplicate entry&#8221;\u95ee\u9898\u3002\u4e5f\u63d0\u5230\u4e86\uff0c\u53ef\u4ee5\u5728\u811a\u672c\u4e2d\u6dfb\u52a0hook\u7684\u65b9\u5f0f\u89e3\u51b3\uff0c\u4e0d\u8fc7\u4e4b\u524d\u5e76\u6ca1\u6709\u5bf9\u8fd9\u4e2a\u65b9\u6848\u8fdb\u884c\u9a8c\u8bc1\u3002 \u5728\u6d4b\u8bd5\u811a\u672c\u4e2d\u4f7f\u7528hook\u7684\u65b9\u6848\uff0c\u5728sysbench\u7684\u6587\u6863\u4e2d\u5e76\u6ca1\u6709\u627e\u5230\u8be6\u7ec6\u7684\u8bf4\u660e\uff0c\u8fd9\u91cc\u5c06\u5bf9\u8fd9\u4e2a\u65b9\u6848\u505a\u4e00\u4e2a\u4f7f\u7528\u8bf4\u660e\uff0c\u5e76\u9a8c\u8bc1\u5176\u6709\u6548\u6027\u3002\u6211\u4eec\u5c06\u5206\u4e24\u7ec4\u5bf9\u6bd4\u6d4b\u8bd5\uff0c\u9a8c\u8bc1\u65b0\u589ehook\u7684\u6709\u6548\u6027\uff0c\u4ee5\u53ca\u65b0\u589ehook\u540e\uff0c\u5bf9\u6d4b\u8bd5\u7ed3\u679c\u662f\u5426\u5bf9\u6027\u80fd\u6709\u5f71\u54cd\u3002 \u6d4b\u8bd5\u7ed3\u679c\u6982\u8ff0 Sysbench\u7684\u8be5\u80fd\u529b\u5e76\u6ca1\u6709\u5728\u6587\u6863\u4e2d\u627e\u5230\u8bf4\u660e\uff0c\u53ea\u662f\u5728\u4e00\u4e2aSlide\u4e2d\u770b\u5230\u7684\u3002\u672c\u6587\u7684\u6d4b\u8bd5\u9a8c\u8bc1\u4e86\u5982\u4e0b\u5185\u5bb9\uff1a \u6240\u4ee5\uff0c\u540e\u7eed\u6d4b\u8bd5\u4e2d\uff0c\u5982\u679c\u4e0d\u53ef\u907f\u514d\u7684\u4f1a\u9047\u5230\u201dDuplicate entry\u201d\u62a5\u9519\uff08\u6216\u5176\u4ed6\u62a5\u9519\uff09\u65f6\uff0c\u5c06\u4f7f\u7528hook\u7684\u65b9\u5f0f\u6765\u907f\u514d\u3002 \u5982\u4f55\u4fee\u6539\u6d4b\u8bd5\u811a\u672c \u5177\u4f53\u7684\uff0c\u6211\u4eec\u5728\u539f\u6765\u7684oltp_read_write\uff08sysbench 1.0.20\u7248\u672c\uff09\u811a\u672c\u4e2d\u65b0\u589e\u5982\u4e0b\u4ee3\u7801\u7247\u6bb5\uff1a \u5b8c\u6574\u7684\u4ee3\u7801\u53ef\u4ee5\u53c2\u8003\uff1aoltp_read_write_with_hooks.lua \u5177\u4f53\u7684diff\u6587\u4ef6\u53c2\u8003\u5982\u4e0b\uff1a \u6d4b\u8bd5\u8bf4\u660e \u8fd9\u91cc\u4f9d\u65e7\u4f7f\u7528oltp_read_write\u8d1f\u8f7d\u8fdb\u884c\u6d4b\u8bd5\uff0c\u6d4b\u8bd5\u65f6\u4f7f\u7528\u4e86\u53c2\u6570 &#8211;skip_trx=on &#8211;db-ps-mode=disable &#8211;rand-type=uniform \uff0c\u5176\u4e2d\u53c2\u6570&#8211;skip_trx=on\u4f1a\u5e26\u6765\u201dDuplicate entry\u201d\u62a5\u9519\uff0c\u5e76\u5bfc\u81f4\u6d4b\u8bd5\u88ab\u7ec8\u6b62\uff08\u8be6\u7ec6\u539f\u56e0\u5206\u6790\u53c2\u8003\uff1aSysbench\u538b\u6d4bMySQL\u4e2d\u9047\u5230\u7684\u201dDuplicate entry\u201d\u95ee\u9898\uff09\u3002\u6d4b\u8bd5\u5206\u4e24\u7ec4\uff0c\u4e00\u7ec4\u662f\u4f7f\u7528\u539f\u59cb\u7684oltp_read_write\u811a\u672c\u8fdb\u884c\u6d4b\u8bd5\uff1b\u53e6\u4e00\u7ec4\uff0c\u5219\u5728\u811a\u672c\u4e2d\u65b0\u589e\u4e0a\u8ff0hook\u4ee3\u7801\u3002 \u800c\u540e\u89c2\u6d4b\uff1a \u8fd9\u91cc\u7684sysbench_auto.sh\u662f\u4e00\u4e2a\u81ea\u5df1\u7f16\u5199\u7684\u81ea\u52a8\u5316\u7684sysbench\u6d4b\u8bd5\u811a\u672c\u3002\u4f1a\u81ea\u52a8\u5316\u7684\u3001\u987a\u5e8f\u7684\u8fdb\u884c\u591a\u4e2a\u4e0d\u540c\u5e76\u53d1\u4e0b\u7684\u6027\u80fd\u6d4b\u8bd5\u3002 \u6d4b\u8bd5\u7ed3\u679c\u8be6\u60c5 \u6ca1\u6709\u4f7f\u7528hook\u7684\u6d4b\u8bd5\u4e2d\uff0c\u6ce8\u610f\u5230\uff0c\u5728\u5e76\u53d1\u5ea6\u4e3a48\u300196\u3001128\u3001192\u65f6\u5019\uff0c\u6d4b\u8bd5\u88ab\u7ec8\u6b62\uff0c\u800c\u89c2\u6d4b\u65e5\u5fd7\u4e5f\u770b\u5230\u4e86\u662f\u56e0\u4e3a\u201cDuplicate entry\u201d\u6240\u5bfc\u81f4\u7684\u3002 \u5177\u4f53\u62a5\u9519\uff1a \u5728\u4f7f\u7528\u4e86hook\u7684\u6d4b\u8bd5\u4e2d\uff0c\u6ce8\u610f\u5230\uff0c\u6d4b\u8bd5\u987a\u5229\u7684\u5b8c\u6210\u4e86\uff0c\u5e76\u6ca1\u6709\u88ab\u7ec8\u6b62\uff0c\u800c\u89c2\u5bdf\u65e5\u5fd7\uff0c\u4e5f\u53ef\u4ee5\u770b\u5230\uff0c\u671f\u95f4\u4e5f\u662f\u9047\u5230\u4e86Duplicate entry\u62a5\u9519\u7684\uff0c\u4f46\u56e0\u4e3ahook\u7684\u5904\u7406\uff0c\u6d4b\u8bd5\u5e76\u6ca1\u6709\u7ec8\u6b62\u3002 \u4e24\u7ec4\u6d4b\u8bd5\u6027\u80fd\u7684\u5bf9\u6bd4 \u6839\u636e\u5982\u4e0a\u6027\u80fd\u6d4b\u8bd5\u6570\u636e\uff0c\u5bf9QPS\uff08Queries Per Second\uff09\u8fdb\u884c\u5bf9\u6bd4\uff1a \u53ef\u4ee5\u770b\u5230\uff0c\u6574\u4f53\u6027\u80fd\u6ce2\u52a8\u975e\u5e38\u5c0f\uff0c\u4f18\u52bf\u5728\u8f83\u9ad8\u5e76\u53d1\u65f6\uff0c\u6027\u80fd\u5dee\u5f02\u90fd\u5c0f\u4e8e1%\uff1b\u4ece\u8d8b\u52bf\u56fe\u4e0a\u4e5f\u80fd\u591f\u770b\u51fa\u6765\uff0c\u4e24\u8005\u51e0\u4e4e\u662f\u91cd\u5408\u7684\u3002 \u66f4\u591a\u6d4b\u8bd5\u539f\u59cb\u6570\u636e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"a-temp-temp","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10974","post","type-post","status-publish","format-standard","hentry","category-simplelife"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/10974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=10974"}],"version-history":[{"count":45,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/10974\/revisions"}],"predecessor-version":[{"id":11060,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/10974\/revisions\/11060"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=10974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=10974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=10974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}