{"id":33490,"date":"2023-01-05T09:12:42","date_gmt":"2023-01-05T01:12:42","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=33490"},"modified":"2023-01-05T09:13:40","modified_gmt":"2023-01-05T01:13:40","slug":"mysql-bug","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/mysql-bug.html","title":{"rendered":"\u60b2\u5267\u554a\uff01Mysql\u7684\u4e0a\u53e4BUG\uff01\uff01\uff01"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u662fMySQL8.0\u4fee\u590d\u7684\u4e0a\u53e4bug\u4e4b\u4e00\uff0c\u57282003\u5e74\u7531Percona\u7684CEO\uff08\u5f53\u65f6\u5e94\u8be5\u8fd8\u6ca1Percona\u5427\uff09\u63d0\u51fa\u7684bug#199\uff0c\u5149\u770b\u8fd9bug\u53f7\u5c31\u6251\u9762\u800c\u6765\u4e00\u80a1\u4e0a\u53e4\u65f6\u4ee3\u7684\u6ca7\u6851\u6c14\u606f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"u6024910391627713456fm21gp0\"
\n\u95ee\u9898\u7684\u672c\u8d28\u5728\u4e8eInnoDB\u521d\u59cb\u5316AUTO_INCREMENT\u7684\u65b9\u5f0f\uff0c\u5728\u6bcf\u6b21\u91cd\u542f\u65f6\uff0c\u603b\u662f\u7b97\u51fa\u8868\u4e0a\u6700\u5927\u7684\u81ea\u589e\u503c\u4f5c\u4e3a\u6700\u5927\u503c\uff0c\u4e0b\u4e00\u6b21\u5206\u914d\u4ece\u8be5\u503c\u5f00\u59cb\u3002\u8fd9\u610f\u5473\u7740\u5982\u679c\u5728btree\u53f3\u4fa7\u53f6\u8282\u70b9\u5927\u91cf\u5220\u9664\u8bb0\u5f55\uff0c\u91cd\u542f\u540e\uff0c\u81ea\u589e\u503c\u53ef\u80fd\u88ab\u91cd\u7528\u3002\u8fd9\u5728\u5f88\u591a\u573a\u666f\u4e0b\u53ef\u80fd\u5bfc\u81f4\u95ee\u9898\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a\u4e3b\u5907\u5207\u6362\u3001\u5386\u53f2\u6570\u636e\u8fc1\u79fb\u7b49\u573a\u666f\u3002\u5728bug#199\u4e0b\u9762\u4e00\u5927\u5806\u7684\u56de\u590d\u91cc\uff0c\u53ef\u4ee5\u770b\u5230\u5927\u91cf\u7684\u540c\u884c\u62b1\u6028\u3002<\/p>\n

\u5b98\u65b9\u7684\u4fee\u590d\u5c31\u6bd4\u8f83\u4f18\u96c5\u4e86\uff0c\u4e0d\u6539\u53d8\u4efb\u4f55\u73b0\u6709\u7684\u5b58\u50a8\uff0c\u800c\u662f\u901a\u8fc7redo log\u6765\u8fdb\u884c\u6062\u590d\u3002\u8be5\u8865\u4e01\u57fa\u4e8eWL#7816\u7684\u6846\u67b6\u5b9e\u73b0\u7684\uff0c\u8981\u60f3\u641e\u61c2\u8fd9\u4e2a\u8865\u4e01\uff0c\u5f97\u5148\u770b\u770bWL#7816\u505a\u4e86\u54ea\u4e9b\u6539\u52a8\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cInnoDB\u4f7f\u7528\u4e00\u4e2a\u5f15\u64ce\u79c1\u6709\u7684\u7cfb\u7edf\u8868+\u7279\u6b8aredo log\u7684\u65b9\u5f0f\uff0c\u5728\u5f15\u64ce\u5185\u90e8\u81ea\u5df1\u89e3\u51b3corruption\u6807\u8bb0\u6301\u4e45\u5316\u7684\u95ee\u9898\u3002\u5176\u5927\u6982\u601d\u8def\u4e3a\uff1a<\/p>\n

    \n
  1. \u5f53\u53d1\u73b0\u7d22\u5f15\u635f\u574f\u65f6\uff0c\u5199\u5165\u4e00\u6761redo log\uff0c\u4f46\u4e0d\u66f4\u65b0\u6570\u636e\u8bcd\u5178<\/li>\n
  2. \u5f15\u5165\u4e00\u4e2ainnodb\u5f15\u64ce\u79c1\u6709\u7684\u7cfb\u7edf\u8868\uff0c\u79f0\u4e3aDD Buffer Table\uff0c\u6bcf\u6b21checkpoint\u4e4b\u524d\u4f1a\u5c06\u7d22\u5f15corruption bit\u5b58\u5165\u5176\u4e2d\u3002<\/li>\n
  3. \u5728\u5d29\u6e83\u6062\u590d\u65f6\uff0c\u540c\u65f6\u4eceredo log\u548cDD Buffer Table\u4e2d\u8bfb\u53d6\u7d22\u5f15 corruption bit, \u5408\u5e76\u7ed3\u679c\uff0c\u5e76\u6807\u8bb0\u5185\u5b58\u4e2d\u7684\u8868\u548c\u7d22\u5f15\u5bf9\u8c61\u3002<\/li>\n<\/ol>\n
    \u521d\u59cb\u5316Persister<\/strong><\/div>\n

    \u76ee\u524dPersister\u7684\u7c7b\u578b\u4ec5\u6709\u4e24\u79cd\uff0c\u4e00\u4e2a\u7528\u4e8ecorruption bit\u7684\u6301\u4e45\u5316\uff0c\u4e00\u4e2a\u7528\u4e8e\u81ea\u589e\u5217\u7684\u6301\u4e45\u5316\uff0c\u5bf9\u5e94\u7684\u7c7b\u4e3a\uff1a<\/p>\n

    Persister:\r\n    |-- CorruptedIndexPersister\r\n    |-- AutoIncPersister\r\n<\/pre>\n

    Persister\u5bf9\u5e94\u5168\u5c40\u5bf9\u8c61dict_persist_t::persisters\uff0c\u53ef\u4ee5\u901a\u8fc7\u7c7b\u578bpersistent_type_t\u6765\u627e\u5230\u5bf9\u5e94\u7684Persister\uff0c\u76ee\u524d\u4ec5\u6709PM_INDEX_CORRUPTED\u53caPM_TABLE_AUTO_INC\uff0c\u4f46\u4ece\u6ce8\u91ca\u6765\u770b\uff0c\u672a\u6765\u80af\u5b9a\u4f1a\u505a\u66f4\u591a\u7684\u6269\u5c55\uff0cPersister\u5728\u542f\u52a8\u65f6\u8c03\u7528\u51fd\u6570dict_persist_init\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/p>\n

    \u65b0\u7684\u7cfb\u7edf\u8868<\/strong><\/div>\n

    \u65b0\u7684\u7cfb\u7edf\u8868\u540d\u4e3aSYS_TABLE_INFO_BUFFER\uff0c\u5bf9\u5e94\u7ba1\u7406\u7c7b\u4e3aDDTableBuffer\uff0c\u6307\u9488\u5b58\u50a8\u5728dict_persist->table_buffer\u4e2d\u3002<\/p>\n

    \u7cfb\u7edf\u8868\u5305\u542b\u4e24\u4e2a\u5217\uff1aTABLE_ID\u53caBLOB\u7c7b\u578b\u7684METADATA\uff08ref DDTableBuffer::init\uff09\uff0cMETADATA\u5217\u5305\u542b\u4e86\u6240\u6709\u9700\u8981\u6301\u4e45\u5316\u7684\u5143\u6570\u636e\u3002<\/p>\n

    \u56de\u5199DDTableBuffer<\/strong><\/div>\n

    \u6709\u51e0\u79cd\u60c5\u51b5\u4f1a\u5c06\u5185\u5b58\u4fee\u6539\u56de\u5199\u5230DDTableBuffer\u4e2d\uff1a<\/p>\n

      \n
    1. \u5728\u505acheckpoint(log_checkpoint)\u4e4b\u524d\uff0c\u6240\u6709\u5728dirty_dict_tables\u94fe\u8868\u4e0a\u7684\u8868\u5bf9\u8c61\uff0c\u5bf9\u5e94persist metadata\u90fd\u9700\u8981\u56de\u5199\u5230DDTableBuffer\u4e2d(dict_persist_to_dd_table_buffer)<\/li>\n
    2. \u4ece\u5185\u5b58\u4e2d\u9a71\u9010\u4e00\u4e2a\u8868\u5bf9\u8c61\u65f6(dict_table_remove_from_cache_low)\uff0c\u5982\u679c\u9700\u8981\u7684\u8bdd\u4e5f\u4f1a\u53bb\u5c1d\u8bd5\u56de\u5199\u3002<\/li>\n
    3. \u5728\u5bf9\u5305\u542b\u81ea\u589e\u5217\u7684\u8868\u505aDDL\u540e\uff0c\u9700\u8981\u6301\u4e45\u5316counter\uff0c\u5728\u5982\u4e0b\u51fd\u6570\u4e2d\uff0c\u4f1a\u8c03\u7528dict_table_set_and_persist_autoinc:<\/li>\n<\/ol>\n
      ha_innobase::commit_inplace_alter_table\r\ncreate_table_info_t::initialize_autoinc()\r\n\/\/ for example: alter<\/span> table<\/span>..auto_increment = ??\r\nrow_rename_table_for_mysql;<\/span>\r\n\/\/ rename<\/span> from<\/span> temporary<\/span> table<\/span> to<\/span> normal<\/span> table<\/span>\r\n<\/span><\/pre>\n

      \u56de\u5199\u7684\u8fc7\u7a0b\u4e5f\u6bd4\u8f83\u7b80\u5355(dict_table_persist_to_dd_table_buffer_low)\uff1a<\/p>\n

        \n
      1. \u901a\u8fc7\u8868\u5bf9\u8c61\u521d\u59cb\u5316\u9700\u8981\u56de\u5199\u7684Metadata\u6570\u636e: corrupt index\u53caautoinc\u503c(dict_init_dynamic_metadata)<\/li>\n
      2. \u6784\u5efa\u8bb0\u5f55\u503c\uff0c\u63d2\u5165DDTableBuffer\u7cfb\u7edf\u8868(DDTableBuffer::replace(), \u5982\u679c\u8bb0\u5f55\u5b58\u5728\u7684\u8bdd\uff0c\u5219\u8fdb\u884c\u60b2\u89c2\u66f4\u65b0\u64cd\u4f5c<\/li>\n
      3. \u8868\u5bf9\u8c61\u7684diry_status\u4fee\u6539\u6210 METADATA_BUFFERED\uff0c\u8868\u793a\u6709buffer\u7684\u5143\u6570\u636e<\/li>\n<\/ol>\n
        Recovery and Startup<\/strong><\/div>\n

        \u5728\u5d29\u6e83\u6062\u590d\u65f6\uff0c\u5f53\u89e3\u6790\u5230\u65e5\u5fd7MLOG_TABLE_DYNAMIC_META\u65f6(MetadataRecover::parseMetadataLog)\uff0c\u4f1a\u8fdb\u884c\u89e3\u6790\u5e76\u5c06\u89e3\u6790\u5f97\u5230\u7684\u6570\u636e\u5b58\u50a8\u5230\u96c6\u5408\u4e2d(MetadataRecover::m_tables)\uff0c\u5982\u679c\u5b58\u5728\u76f8\u540ctable-id\u7684\u9879\uff0c\u5c31\u8fdb\u884c\u66ff\u6362\uff0c\u786e\u4fdd\u603b\u662f\u6700\u65b0\u7684\u3002<\/p>\n

        \u5728\u5b8c\u6210recovery\u540e\uff0c\u641c\u96c6\u5230\u7684meta\u4fe1\u606f\u6682\u65f6\u5b58\u50a8\u5230srv_dict_metadata\u4e2d\uff0c \u968f\u540e\u8fdb\u884capply(srv_dict_recover_on_restart)\uff0c apply\u7684\u8fc7\u7a0b\u4e5f\u6bd4\u8f83\u7b80\u5355\uff0c\u8f7d\u5165\u8868\u5bf9\u8c61\uff0c\u7136\u540e\u5bf9\u8868\u5bf9\u8c61\u8fdb\u884c\u66f4\u65b0\uff08MetadataRecover::apply\uff09\uff0c\u4f8b\u5982\u5bf9\u4e8eautoinc\u5217\uff0c\u5c31\u603b\u662f\u9009\u62e9\u66f4\u5927\u7684\u90a3\u4e2a\u503c\u3002<\/p>\n

        \u6700\u540e<\/strong><\/div>\n

        \u8fd9\u4e2abug\u5df2\u7ecf\u6302\u4e86\u76f8\u5f53\u957f\u7684\u65f6\u95f4\uff0c\u4e0d\u6392\u9664\u628a\u8fd9\u4e2abug\u5f53\u4f5cInnoDB\u7684\u201c\u7279\u6027\u201d\u7684\u540c\u5b66\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u5230\u8fd9\u4e2a\u6539\u52a8...<\/p>\n

        \n

        \u539f\u6587\u6765\u81ea\uff1ahttps:\/\/yq.aliyun.com\/articles\/60885?utm_campaign=wenzhang&utm_medium=article&utm_source=QQ-qun&utm_content=m_6383<\/a><\/p>\n

        \u672c\u6587\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/mysql-bug.html<\/a> \u7f16\u8f91\uff1a\u5cb3\u56fd\u5e05\uff0c\u5ba1\u6838\u5458\uff1a\u51af\u742a<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

        \u5bfc\u8bfb \u8fd9\u662fMySQL8.0\u4fee\u590d\u7684\u4e0a\u53e4bug\u4e4b\u4e00\uff0c\u57282003\u5e74\u7531Percona\u7684CEO\uff08\u5f53\u65f6\u5e94\u8be5\u8fd8\u6ca1Percon […]<\/p>\n","protected":false},"author":63,"featured_media":33501,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-33490","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/33490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=33490"}],"version-history":[{"count":13,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/33490\/revisions"}],"predecessor-version":[{"id":261095,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/33490\/revisions\/261095"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/33501"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=33490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=33490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=33490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}