{"id":695,"date":"2023-10-09T22:57:11","date_gmt":"2023-10-09T13:57:11","guid":{"rendered":"https:\/\/skanto.co.kr\/?p=695"},"modified":"2023-10-09T23:03:49","modified_gmt":"2023-10-09T14:03:49","slug":"mysql-%ec%98%a4%eb%a5%98-%ec%88%98%ec%a0%95-warning-got-packets-out-of-order-expected-10-but-received-0","status":"publish","type":"post","link":"https:\/\/skanto.co.kr\/?p=695","title":{"rendered":"MySQL \uc624\ub958 \uc218\uc815: Warning: got packets out of order. Expected 10 but received 0"},"content":{"rendered":"\n<p>MySQL\uc5d0\uc11c \uc5b8\uc81c\ubd80\ud134\uac00 \uc544\ub798\uc640 \uac19\uc740 \uba54\uc2dc\uc9c0\uac00 \ucf58\uc194 \ub85c\uadf8\uc5d0 \ub208\uc5d0 \ub744\uae30 \uc2dc\uc791\ud55c\ub2e4. \uadf8 \uc804\ubd80\ud130 \uc624\ub958 \uba54\uc2dc\uc9c0\uac00 \uc788\uc5c8\ub294\ub370 \ud655\uc778\uc744 \ubabb\ud558\uace0 \uc788\uc5c8\uc744 \uc218\ub3c4 \uc788\ub2e4. \ub370\uc774\ud130 \ubca0\uc774\uc2a4 \ub3d9\uc791\uc5d0\ub294 \ubb38\uc81c\uac00 \ub418\uc9c0 \uc54a\ub294\ub370 \uacbd\uace0 \uba54\uc2dc\uc9c0\uac00 \uacc4\uc18d \ub208\uc5d0 \uac70\uc2ac\ub824 \uc218\uc815\ud574 \ubcf4\uae30\ub85c \ud558\uace0 \uba87 \uc2dc\uac04\uc744 \ud22c\uc790 \ud55c \uacb0\uacfc \uc6d0\uc778\uacfc \ud574\uacb0 \ubc29\ubc95\uc744 \uc54c\uc544 \ub0c8\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Warning: got packets out of order. Expected 10 but received 0\nWarning: got packets out of order. Expected 10 but received 7\n...\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud604\uc0c1 \uc7ac\uc5f0<\/h2>\n\n\n\n<p>\uc815\ud655\ud55c \ud604\uc0c1 \uc7ac\uc5f0\uc740 \uc544\ub798\uc640 \uac19\ub2e4.<\/p>\n\n\n\n<p>Nodejs\uc758 mysql2 db connection\ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ud65c\uc6a9\ud558\uba70 \ub370\uc774\ud130 \ubca0\uc774\uc2a4 \uc624\ud37c\ub808\uc774\uc158 \ud6c4 \uc815\ud655\ud558\uac8c 8\uc2dc\uac04(28,800\ucd08)\uc774 \uc9c0\ub098\uba74 \uc704\uc758 \ub85c\uadf8 \uba54\uc2dc\uc9c0\uac00 \ucd9c\ub825\ub41c\ub2e4.<\/p>\n\n\n\n<p>\uc880 \ub354 \uc27d\uac8c \ud604\uc0c1\uc744 \uc7ac\uc5f0\ud558\ub824\uba74 mysql \uc758 \uc124\uc815\ud30c\uc77c\uc778 \/etc\/mysql\/mysql.cnf \uc5d0 \uc544\ub798\uc758 \uc18d\uc131\uc744 \ucd94\uac00 \ud55c \ud6c4 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n&#91;mysqld] \nwait_timeout = 5 \ninteractive_timeout = 5<\/code><\/pre>\n\n\n\n<p>\uc544\ub798\uc758 \uba85\ub839\uc5b4\ub85c MySQL\uc758 \uc7ac\uc2dc\uc791 \ud55c\ub2e4. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl restart mysql<\/code><\/pre>\n\n\n\n<p>\ubcc0\uacbd\ub41c \uc18d\uc131\uc758 \ubc18\uc601 \uc5ec\ubd80\ub294 \uc544\ub798\uc640 \uac19\uc774 mysql\uc744 \uc811\uc18d\ud558\uc5ec \ud655\uc778\uc774 \uac00\ub2a5\ud558\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ mysql -u root -p\nEnter password: \nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 121\nServer version: 8.0.34-0ubuntu0.22.04.1 (Ubuntu)\n\nCopyright (c) 2000, 2023, Oracle and\/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql&gt; show variables like '%timeout';\n+-----------------------------------+----------+\n| Variable_name                     | Value    |\n+-----------------------------------+----------+\n| connect_timeout                   | 10       |\n| delayed_insert_timeout            | 300      |\n| have_statement_timeout            | YES      |\n| innodb_flush_log_at_timeout       | 1        |\n| innodb_lock_wait_timeout          | 50       |\n| innodb_rollback_on_timeout        | OFF      |\n| interactive_timeout               | 5        |\n| lock_wait_timeout                 | 31536000 |\n| mysqlx_connect_timeout            | 30       |\n| mysqlx_idle_worker_thread_timeout | 60       |\n| mysqlx_interactive_timeout        | 28800    |\n| mysqlx_port_open_timeout          | 0        |\n| mysqlx_read_timeout               | 30       |\n| mysqlx_wait_timeout               | 28800    |\n| mysqlx_write_timeout              | 60       |\n| net_read_timeout                  | 30       |\n| net_write_timeout                 | 60       |\n| replica_net_timeout               | 60       |\n| rpl_stop_replica_timeout          | 31536000 |\n| rpl_stop_slave_timeout            | 31536000 |\n| slave_net_timeout                 | 60       |\n| ssl_session_cache_timeout         | 300      |\n| wait_timeout                      | 5        |\n+-----------------------------------+----------+\n23 rows in set (0.00 sec)<\/code><\/pre>\n\n\n\n<p>\uc704\uc5d0\uc11c \uc124\uc815\ud55c \uc18d\uc131\uc774 5\ub85c \uc124\uc815\ub41c \uac83\uc73c\ub85c \ud655\uc778\uc774 \ub418\uba74 \uc815\uc0c1\uc801\uc73c\ub85c \ubc18\uc601\ub41c \uac83\uc774\ub2e4.(default: 28800)<\/p>\n\n\n\n<p>MySQL\uc744 \uc7ac\uc2dc\uc791 \ud6c4 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc624\ud37c\ub808\uc774\uc158(\uac80\uc0c9) \ud6c4 5\ucd08\uac00 \uc9c0\ub098\uba74 \ucf58\uc194\uc5d0 \uacbd\uace0\uba54\uc2dc\uc9c0\uac00 \ucd9c\ub825\ub418\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uc6d0\uc778<\/h2>\n\n\n\n<p>\uacb0\ub860\ubd80\ud130 \uc598\uae30\ud558\uba74 mysql2 \ub4dc\ub77c\uc774\ubc84 \uc774\uc288\uc774\uba70 \ud574\ub2f9 \uc774\uc288\ub294 <a href=\"https:\/\/github.com\/sidorares\/node-mysql2\/pull\/1660\">Github mysql2 \uc774\uc288 \ud2b8\ub798\ucee4<\/a>\uc5d0\uc11c \ud655\uc778\uc774 \uac00\ub2a5\ud558\ub2e4. \uc774 \uae00\uc744 \uc791\uc131\ud558\ub294 \ud604\uc7ac Bug\ub294 fix\ub410\uc73c\ub098 \uc544\uc9c1 Main branch\ub85c merge\ub418\uc9c0\ub294 \uc54a\uc740 \uc0c1\ud0dc\uc774\ub2e4. \ub530\ub77c\uc11c mpm\uc73c\ub85c mysql2\ub97c \ub2e4\uc2dc \uc124\uce58\ud558\ub354\ub77c\ub3c4 \ud574\ub2f9 \uc624\ub958\ub97c \ud574\uacb0\ud558\uc9c0 \ubabb\ud55c\ub2e4.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>From MySQL 8.0.24, an&nbsp;<a href=\"https:\/\/dev.mysql.com\/doc\/mysql-errors\/8.0\/en\/server-error-reference.html#error_er_client_interaction_timeout\">error packet with code 4031<\/a>&nbsp;is sent to client before connection is closed. This packet has sequenceId == 0, thus the connection will issue a warning &#8220;packets out of order&#8221;, which is not correct.<\/p>\n\n\n\n<p>The changes here is just move the block checking &amp; increasing sequence id to go after check for protocol error, since in case of error, we close the connection and return right away.<\/p>\n<\/blockquote>\n\n\n\n<p>\ud574\uc11d\ud558\uc790\uba74 MySQL \ubc84\uc804 8.0.24\ubd80\ud130 connection\uc774 close\ub418\uae30 \uc804\uc5d0 \uc624\ub958 \ud328\ud0b7(\ucf54\ub4dc: 4031, sequenceId: 0)\uc774 \ud074\ub77c\uc774\uc5b8\ud2b8(node driver)\ub85c \uc804\uc1a1\ub418\uba70 \uc774\ub85c \uc778\ud574 \ucf58\uc194\ub85c \uacbd\uace0(Warning) \uba54\uc2dc\uc9c0\uac00 \ucd9c\ub825\ub418\uace0 \uc788\uc5c8\ub2e4. \uc774\ub294 \uc798\ubabb\ub41c \ub3d9\uc791\uc774\uba70 sequence id\ub97c \uac80\uc0ac\ud558\uace0 \uc99d\uac00\uc2dc\ud0a4\ub294 \ucf54\ub4dc  \ube14\ub7ed\uc744 \ud504\ub85c\ud1a0\ucf5c \uc624\ub958 \uac80\uc0ac\ub85c\uc9c1 \uc774\ud6c4\ub85c \uc62e\uacbc\ub2e4\uace0 \ud55c\ub2e4.<\/p>\n\n\n\n<p>Fix\ub41c \uc18c\uc2a4\ucf54\ub4dc\ub294 <a href=\"https:\/\/github.com\/huycn\/node-mysql2\/commit\/389360ee2784ccc34311da7c51298ca92cc6bfba\">\uc774 \uacf3 \uc18c\uc18c\ucf54\ub4dc<\/a>(connecton.js)\uc5d0\uc11c \ud655\uc778\ud560 \uc218 \uc788\ub2e4. 410\ub77c\uc778\ubd80\ud130 \ud655\uc778\ud558\uba74 \ub41c\ub2e4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud574\uacb0<\/h2>\n\n\n\n<p>\ub85c\uceec\uc5d0 \uc124\uce58\ud55c mysql2\uc758 \uc18c\uc2a4\ucf54\ub4dc\ub97c \uc544\ub798\uc640 \uac19\uc774 patch\ud558\uba74 \ub41c\ub2e4. \uba3c\uc800 \ub85c\uceec\uc5d0 \uc124\uce58\ub41c mysql2\uc758 connection.js\ub97c \ucc3e\ub294\ub2e4. \ubcf4\ud1b5 [app]\/node_modules\/mysql2\/lib \ub514\ub809\ud130\ub9ac\uc5d0\uc11c \ud655\uc778\uc774 \uac00\ub2a5\ud558\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>405     \/*\n406     if (packet) { \n407       if (this.sequenceId !== packet.sequenceId) { \n408         const err = new Error( \n409           `Warning: got packets out of order. Expected ${this.sequenceId} bu    t received ${packet.sequenceId}`\n410         ); \n411         err.expected = this.sequenceId; \n412         err.received = packet.sequenceId; \n413         this.emit('warn', err); \/\/ REVIEW \n414         \/\/ eslint-disable-next-line no-console \n415         console.error(err.message); \n416       } \n417       this._bumpSequenceId(packet.numPackets); \n418     } \n419     *\/<\/code><\/pre>\n\n\n\n<p>\uae30\uc874\uc5d0 \uc788\ub294 \ucf54\ub4dc\ub97c \uc8fc\uc11d\ucc98\ub9ac\ud55c \ub2e4\uc74c \ub3d9\uc77c \ucf54\ub4dc\ub97c \uc544\ub798\uc640 \uac19\uc774 \ud504\ub85c\ud1a0\ucf5c\uc744 \uac80\uc0ac\ud558\ub294 \ub85c\uc9c1 \ub4a4\ub85c \uc62e\uaca8 \uc8fc\uba74 \ub41c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>459     if (packet) { \/\/ --&gt; patched by skanto 2023.10.09\n460       \/\/ Note: when server closes connection due to inactivity, Err packet E    R_CLIENT_INTERACTION_TIMEOUT from MySQL 8.0.24, sequenceId will be 0\n461       if (this.sequenceId !== packet.sequenceId) {\n462         const err = new Error(\n463           `Warning: got packets out of order. Expected ${this.sequenceId} bu    t received ${packet.sequenceId}`\n464         );\n465         err.expected = this.sequenceId;\n466         err.received = packet.sequenceId;\n467         this.emit('warn', err); \/\/ REVIEW\n468         \/\/ eslint-disable-next-line no-console\n469         console.error(err.message);\n470       }\n471       this._bumpSequenceId(packet.numPackets);\n472     } \/\/ &lt;--\n<\/code><\/pre>\n\n\n\n<p>\uc774\ub807\uac8c \ucf54\ub4dc\ub97c \uc218\uc815\ud558\uace0 node \ud504\ub85c\uadf8\ub7a8\uc744 \uc7ac\uc2e4\ud589\ud558\uba74 \uacbd\uace0 \uba54\uc2dc\uc9c0\uac00 \ub354\uc774\uc0c1 \ubc1c\uc0dd\ub418\uc9c0 \uc54a\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<p>\ub9c8\uc9c0\ub9c9\uc73c\ub85c, \ucc98\uc74c\uc5d0 \uc124\uc815\ud588\ub358 MySQL \uc124\uc815 \uac12\uc744 default\uac12\uc73c\ub85c \ub418\ub3cc\ub824 \uc8fc\uace0(\uc124\uc815\ud588\ub358 \uc18d\uc131\uc744 \uc8fc\uc11d\ucc98\ub9ac) MySQL\uc744 \uc7ac\uc2e4\ud589\ud574 \uc8fc\uba74 \ub41c\ub2e4. \uc0c1\ud669\uc885\ub8cc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\uc5d0\uc11c \uc5b8\uc81c\ubd80\ud134\uac00 \uc544\ub798\uc640 \uac19\uc740 \uba54\uc2dc\uc9c0\uac00 \ucf58\uc194 \ub85c\uadf8\uc5d0 \ub208\uc5d0 \ub744\uae30 \uc2dc\uc791\ud55c\ub2e4. \uadf8 \uc804\ubd80\ud130 \uc624\ub958 \uba54\uc2dc\uc9c0\uac00 \uc788\uc5c8\ub294\ub370 \ud655\uc778\uc744 \ubabb\ud558\uace0 \uc788\uc5c8\uc744 \uc218\ub3c4 \uc788\ub2e4. \ub370\uc774\ud130 \ubca0\uc774\uc2a4 \ub3d9\uc791\uc5d0\ub294 \ubb38\uc81c\uac00 \ub418\uc9c0 \uc54a\ub294\ub370 \uacbd\uace0 \uba54\uc2dc\uc9c0\uac00 \uacc4\uc18d \ub208\uc5d0 \uac70\uc2ac\ub824 \uc218\uc815\ud574 \ubcf4\uae30\ub85c \ud558\uace0 \uba87 \uc2dc\uac04\uc744 \ud22c\uc790 \ud55c \uacb0\uacfc \uc6d0\uc778\uacfc \ud574\uacb0 \ubc29\ubc95\uc744 \uc54c\uc544 \ub0c8\ub2e4. \ud604\uc0c1 \uc7ac\uc5f0 \uc815\ud655\ud55c \ud604\uc0c1 \uc7ac\uc5f0\uc740 \uc544\ub798\uc640 \uac19\ub2e4. Nodejs\uc758 mysql2 db connection\ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ud65c\uc6a9\ud558\uba70 \ub370\uc774\ud130 \ubca0\uc774\uc2a4 \uc624\ud37c\ub808\uc774\uc158 \ud6c4 \uc815\ud655\ud558\uac8c 8\uc2dc\uac04(28,800\ucd08)\uc774 \uc9c0\ub098\uba74 \uc704\uc758 \ub85c\uadf8 \uba54\uc2dc\uc9c0\uac00 \ucd9c\ub825\ub41c\ub2e4. \uc880 \ub354 \uc27d\uac8c \ud604\uc0c1\uc744 \uc7ac\uc5f0\ud558\ub824\uba74 mysql \uc758 \uc124\uc815\ud30c\uc77c\uc778 \/etc\/mysql\/mysql.cnf \uc5d0 \uc544\ub798\uc758 \uc18d\uc131\uc744 \ucd94\uac00&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/skanto.co.kr\/?p=695\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[14],"tags":[79,80,81],"class_list":["post-695","post","type-post","status-publish","format-standard","hentry","category-sw-development","tag-mysql","tag-nodejs","tag-warning"],"_links":{"self":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=695"}],"version-history":[{"count":3,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/695\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/695\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}