{"id":2051,"date":"2020-07-29T23:27:47","date_gmt":"2020-07-29T15:27:47","guid":{"rendered":"http:\/\/39.97.231.10\/?p=2051"},"modified":"2020-07-29T23:27:47","modified_gmt":"2020-07-29T15:27:47","slug":"mysql-%e4%b8%bb%e4%bb%8e%e5%b9%82%e7%ad%89%e5%a4%8d%e5%88%b6slave_exec_modeidempotent","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=2051","title":{"rendered":"MySQL \u4e3b\u4ece\u5e42\u7b49\u590d\u5236slave_exec_mode=IDEMPOTENT"},"content":{"rendered":"<p>MySQL slave_exec_mode \u53c2\u6570\u7528\u4e8e\u63a7\u5236\u4e3b\u4ece\u590d\u5236\u6570\u636e\u51b2\u7a81\u65f6\u7684\u5904\u7406\u7b56\u7565\uff0c\u53ef\u9009\u503c\u6709STRICT\u548cIDEMPOTENT\uff0c\u5206\u522b\u4ee3\u8868\u4e25\u683c\u6a21\u5f0f\u548c\u5e42\u7b49\u6a21\u5f0f\uff0c\u9ed8\u8ba4\u503c\u4e3aSTRICT\uff0c\u8be5\u53c2\u6570\u53ef\u52a8\u6001\u8c03\u6574\u3002<\/p>\n<ul>\n<li>STRICT\uff0c\u4e25\u683c\u6a21\u5f0f<\/li>\n<li>IDEMPOTENT\uff0c\u5e42\u7b49\u6a21\u5f0f<\/li>\n<\/ul>\n<p>\u9ed8\u8ba4STRICT\u6a21\u5f0f\u4e0b\uff0c\u4ece\u5e93\u590d\u5236\u8fc7\u7a0b\u4e2d\uff0c\u53d1\u73b0\u6570\u636e\u51b2\u7a81\uff0c\u4f1a\u7acb\u5373\u62a5\u9519\uff0c\u5e76\u4e2d\u65ad\u590d\u5236\u7ebf\u7a0b\u3002\u8bbe\u7f6e\u4e3aIDEMPOTENT\uff0c\u9047\u5230\u4e3b\u952e\u6216\u552f\u4e00\u952e\u51b2\u7a81\u4ee5\u53ca\u4e3b\u952e\u4e0d\u5b58\u5728\u65f6\uff0c\u5e76\u4e0d\u4f1a\u62a5\u9519\uff0c\u4f1a\u76f4\u63a5\u8986\u76d6\u6570\u636e\u6216\u8005\u5ffd\u7565\u6570\u636e\u4e0d\u5b58\u5728\uff0c\u4e3b\u4ece\u590d\u5236\u4ecd\u7136\u6b63\u5e38\u8fdb\u884c\u3002\u8bbe\u7f6e\u8fd9\u4e2a\u53c2\u6570\u5c06\u4f1a\u7acb\u5373\u751f\u6548\uff0c\u5e76\u4e0d\u9700\u8981\u91cd\u542f\u590d\u5236\u3002<\/p>\n<h4>\u4e00\u3001IDEMPOTENT\u5e42\u7b49\u590d\u5236\u6d4b\u8bd5<\/h4>\n<ul>\n<li>MySQL \u7248\u672c 5.7.19<\/li>\n<li>binlog_format\uff1aROW<\/li>\n<\/ul>\n<p>\u8868\u7ed3\u6784\uff1aid\u4e3b\u952e\uff0cname varchar(50)<\/p>\n<pre>CREATE TABLE tb (\n\u00a0 id int(11) NOT NULL,\n\u00a0 name varchar(50) DEFAULT NULL,\n\u00a0 PRIMARY KEY (id)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4\n<\/pre>\n<h5>1. insert \u4e3b\u952e\u6216\u552f\u4e00\u952e\u51b2\u7a81<\/h5>\n<p>\u4e3b\u5e93\u8868\u6570\u636e\uff1a\u7a7a<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;1\\&#8217;<br \/>\n\u6b64\u65f6\u5728\u4e3b\u5e93\u63d2\u5165\u6570\u636e,1,\\&#8217;2\\&#8217;<br \/>\n\u7ed3\u679c\uff1a<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;2\\&#8217;\uff0c\u4e3b\u952e\u6216\u552f\u4e00\u952e\u51b2\u7a81\uff0c\u5907\u5e93\u6570\u636e\u4f1a\u88ab\u65b0\u7684insert\u6570\u636e\u8986\u76d6\u3002<\/p>\n<h5>2. update \u5907\u5e93\u6570\u636e\u4e0d\u5b58\u5728<\/h5>\n<p>\u4e3b\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;1\\&#8217;<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a\u7a7a<br \/>\n\u6b64\u65f6\u6267\u884c\uff1aupdate tb set name=\\&#8217;2\\&#8217; where id=1;<br \/>\n\u7ed3\u679c\uff1a<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a\u7a7a\uff0cupdate binlog\u5728\u5907\u5e93\u88ab\u5ffd\u7565\u3002<\/p>\n<h5>3. update \u5907\u5e93\u6570\u636e\u51b2\u7a81<\/h5>\n<p>\u4e3b\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;1\\&#8217;<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;3\\&#8217;<br \/>\n\u6b64\u65f6\u5728\u4e3b\u5e93\u6267\u884c\uff1aupdate tb set name=\\&#8217;2\\&#8217; where id=1;<br \/>\n\u7ed3\u679c\uff1a<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;2\\&#8217;\uff0c\u5907\u5e93\u6570\u636e\u88ab\u8986\u76d6\u3002<\/p>\n<h5>4. delete \u6570\u636e\u4e0d\u5b58\u5728<\/h5>\n<p>\u4e3b\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;1\\&#8217;<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a\u7a7a<br \/>\n\u6b64\u65f6\u5728\u4e3b\u5e93\u6267\u884c\uff1adelete from tb where id=1;<br \/>\n\u7ed3\u679c\uff1a<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a\u7a7a\uff0c\u5907\u5e93\u81ea\u52a8\u5ffd\u7565delete\u4e8b\u4ef6\u3002<\/p>\n<h5>5. delete \u6570\u636e\u4e0d\u4e00\u81f4<\/h5>\n<p>\u4e3b\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;1\\&#8217;<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a1,\\&#8217;2\\&#8217;<br \/>\n\u6b64\u65f6\u5728\u4e3b\u5e93\u6267\u884c\uff1adelete from tb where id=1;<br \/>\n\u7ed3\u679c\uff1a<br \/>\n\u5907\u5e93\u8868\u6570\u636e\uff1a\u7a7a\uff0c\u5907\u5e93\u53ea\u5339\u914d\u4e3b\u952e\u6216\u552f\u4e00\u952e\uff0c\u5176\u4ed6\u5b57\u6bb5\u6570\u636e\u51b2\u7a81\uff0c\u5c06\u88ab\u5ffd\u7565\u3002<\/p>\n<h4>\u4e8c\u3001IDEMPOTENT\u4f7f\u7528\u9650\u5236\uff1a<\/h4>\n<ul>\n<li>\u4e0d\u652f\u6301DDL\u3002<\/li>\n<li>\u5b57\u6bb5\u957f\u5ea6\u4e0d\u540c\u5bfc\u81f4\u7684\u9519\u8bef\u4e0d\u80fd\u5e42\u7b49\uff0c\u6bd4\u5982\u4e3b\u5e93char(5)\uff0c\u4ece\u5e93char(10)\u3002<\/li>\n<li>\u8981\u6709\u4e3b\u952e\u6216\u552f\u4e00\u952e\uff0c\u5e42\u7b49\u6839\u636e\u4e3b\u952e\u6216\u552f\u4e00\u952e\u6765\u5b9e\u73b0\u3002<\/li>\n<\/ul>\n<p>IDEMPOTENT \u6700\u521d\u88ab\u8bbe\u8ba1\u7528\u4e8eMySQL NDB Cluster \u591a\u4e3b\u590d\u5236\u3001\u5faa\u73af\u590d\u5236\u8fd9\u7c7b\u7279\u6b8a\u7684\u573a\u666f\uff0c\u5e76\u4e14NDB\u9ed8\u8ba4\u8bbe\u7f6e\u5c31\u662fIDEMPOTENT\uff0c\u4e5f\u65e0\u6cd5\u8bbe\u7f6e\u4e3a\u5176\u4ed6\u503c\uff0cMySQL\u4e3b\u4ece\u590d\u5236\u4e00\u822c\u5f88\u5c11\u4f7f\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL slave_exec_mode \u53c2\u6570\u7528\u4e8e\u63a7\u5236\u4e3b\u4ece\u590d\u5236\u6570\u636e\u51b2\u7a81\u65f6\u7684\u5904\u7406\u7b56\u7565\uff0c\u53ef\u9009\u503c\u6709STRICT\u548cI &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=2051\"> <span class=\"screen-reader-text\">MySQL \u4e3b\u4ece\u5e42\u7b49\u590d\u5236slave_exec_mode=IDEMPOTENT<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[90,88],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"MySQL slave_exec_mode \u53c2\u6570\u7528\u4e8e\u63a7\u5236\u4e3b\u4ece\u590d\u5236\u6570\u636e\u51b2\u7a81\u65f6\u7684\u5904\u7406\u7b56\u7565\uff0c\u53ef\u9009\u503c\u6709STRICT\u548cI&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2051"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2051"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2051\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2051"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}