{"id":2074,"date":"2020-07-29T23:34:04","date_gmt":"2020-07-29T15:34:04","guid":{"rendered":"http:\/\/39.97.231.10\/?p=2074"},"modified":"2020-07-29T23:34:04","modified_gmt":"2020-07-29T15:34:04","slug":"mysql-8-0-%e6%96%b0%e5%8f%82%e6%95%b0-innodb_idle_flush_pct","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=2074","title":{"rendered":"MySQL 8.0 \u65b0\u53c2\u6570 innodb_idle_flush_pct"},"content":{"rendered":"<div>\n<div>\n<div>\ninnodb_idle_flush_pct \u53c2\u6570\u662f MySQL 8.0.18 \u7248\u672c\u5f15\u5165\u7684\u65b0\u53c2\u6570\uff0c\u7528\u4e8eInnoDB\u7a7a\u95f2\u72b6\u6001\u4e0b\uff0c\u9650\u5236\u5237\u810f\u9875\u7684\u901f\u5ea6\u3002<br \/>\ninnodb_idle_flush_pct\uff1a<\/p>\n<ul>\n<li>\u4f5c\u7528\u8303\u56f4\uff1aGlobal<\/li>\n<li>\u52a8\u6001\u4fee\u6539\uff1aYes<\/li>\n<li>\u9ed8\u8ba4\u503c\uff1a100<\/li>\n<li>\u6700\u5c0f\u503c\uff1a0<\/li>\n<li>\u6700\u5927\u503c\uff1a100<\/li>\n<\/ul>\n<p>innodb_idle_flush_pct \u7684\u503c\u662f\u4e00\u4e2a\u767e\u5206\u6bd4\uff0c\u8be5\u767e\u5206\u6bd4\u4e58\u4ee5\u57fa\u6570\uff0c\u4e5f\u5c31\u662f\u53c2\u6570 innodb_io_capacity \u503c\uff0c\u83b7\u5f97\u7684\u7ed3\u679c\u5373\u4e3aInnoDB\u7a7a\u95f2\u72b6\u6001\u4e0b\u5237\u810f\u9875\u7684\u901f\u5ea6\u3002<br \/>\n\u4e3e\u4e2a\u4f8b\u5b50\uff1a<br \/>\n\u8bbe\u7f6einnodb_io_capacity=1000\uff0c\u8bbe\u7f6einnodb_idle_flush_pct=50\uff0c\u90a3\u4e48\u5728\u7a7a\u95f2\u72b6\u6001\u4e0b\uff0cInnoDB\u5237\u810f\u9875\u7684\u901f\u5ea6\u4e3a 500\u3002<br \/>\ninnodb_idle_flush_pct \u53c2\u6570\u6e90\u7801\u5206\u6790\uff1a<br \/>\n\u6e90\u7801\u7248\u672c\uff1a8.0.20<br \/>\ninnodb_idle_flush_pct\u9ed8\u8ba4\u503c\u4e3a100\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>\/\/ \u6e90\u7801\u6587\u4ef6 srv0srv.cc\nconst ulong srv_idle_flush_pct_default = 100;\nulong srv_idle_flush_pct = srv_idle_flush_pct_default;\n<\/pre>\n<p>\u8c03\u7528\u51fd\u6570buf_flush_lists()\uff0c\u4f20\u5165srv_idle_flush_pct\u53c2\u6570\uff0c\u6765\u63a7\u5236InnoDB\u7a7a\u95f2\u72b6\u6001\u4e0b\u5237\u810f\u9875\u7684\u901f\u5ea6\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>\/\/ \u6e90\u7801\u6587\u4ef6 buf0flu.cc\nelse if (ret_sleep == OS_SYNC_TIME_EXCEEDED &amp;&amp; srv_idle_flush_pct) {\n      \/* no activity, slept enough *\/\n      buf_flush_lists(PCT_IO(srv_idle_flush_pct), LSN_MAX, &amp;n_flushed);\n      }\n<\/pre>\n<p>PCT_IO \u5b8f\u5b9a\u4e49\uff1a<\/p>\n<pre>\/\/ \u6e90\u7801\u6587\u4ef6 srv0srv.h\n#define PCT_IO(p) ((ulong)(srv_io_capacity * ((double)(p) \/ 100.0)))\n<\/pre>\n<p>buf_flush_lists()\u51fd\u6570\uff0c\u8c03\u7528buf_flush_do_batch()\u51fd\u6570\uff0c\u4f20\u5165\u53c2\u6570min_n\uff0c\u63a7\u5236\u5237\u810f\u9875\u901f\u5ea6\uff0c\u4e3b\u8981\u903b\u8f91\u5982\u4e0b\uff1a<\/p>\n<pre>\/\/ \u6e90\u7801\u6587\u4ef6 buf0flu.cc\nbool buf_flush_lists(ulint min_n, lsn_t lsn_limit, ulint *n_processed) {\nif (min_n != ULINT_MAX) {\n\/* Ensure that flushing is spread evenly amongst the\n\u00a0\u00a0\u00a0 buffer pool instances. When min_n is ULINT_MAX\n\u00a0\u00a0\u00a0 we need to flush everything up to the &lt;u&gt;lsn&lt;\/u&gt; limit\n\u00a0\u00a0\u00a0 so no limit here. *\/\n\u00a0\u00a0\u00a0 min_n = (min_n + srv_buf_pool_instances - 1) \/\nsrv_buf_pool_instances;\n\u00a0 }\n    \/* Flush to lsn_limit in all buffer pool instances *\/\n  for (ulint i = 0; i &lt; srv_buf_pool_instances; i++) {\n    buf_pool_t *buf_pool;\n    ulint page_count = 0;\n    buf_pool = buf_pool_from_array(i);\n    if (!buf_flush_do_batch(buf_pool, BUF_FLUSH_LIST, min_n, lsn_limit,\n                            &amp;page_count)) {\n      \/* We have two choices here. If lsn_limit was\n      specified then skipping an instance of buffer\n      pool means we cannot guarantee that all pages\n      up to lsn_limit has been flushed. We can\n      return right now with failure or we can try\n      to flush remaining buffer pools up to the\n      lsn_limit. We attempt to flush other buffer\n      pools based on the assumption that it will\n      help in the retry which will follow the\n      failure. *\/\n      success = false;\n      continue;\n    }\n    n_flushed += page_count;\n  }\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>innodb_idle_flush_pct \u53c2\u6570\u662f MySQL 8.0.18 \u7248\u672c\u5f15\u5165\u7684\u65b0\u53c2\u6570\uff0c\u7528\u4e8eInnoD &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=2074\"> <span class=\"screen-reader-text\">MySQL 8.0 \u65b0\u53c2\u6570 innodb_idle_flush_pct<\/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":"innodb_idle_flush_pct \u53c2\u6570\u662f MySQL 8.0.18 \u7248\u672c\u5f15\u5165\u7684\u65b0\u53c2\u6570\uff0c\u7528\u4e8eInnoD&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2074"}],"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=2074"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/2074\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2074"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}