{"id":10624,"date":"2022-10-25T10:00:59","date_gmt":"2022-10-25T02:00:59","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=10624"},"modified":"2022-10-25T10:01:18","modified_gmt":"2022-10-25T02:01:18","slug":"gbase-8a%e7%9a%84sql%e9%87%8d%e8%af%95%e5%8a%9f%e8%83%bd%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/10624","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u7684SQL\u91cd\u8bd5\u529f\u80fd\u6d4b\u8bd5\uff0cgcluster_query_retry\u53c2\u6570\u4ecb\u7ecd"},"content":{"rendered":"<p>GBase 8a\u652f\u6301\u5728\u67d0\u4e2a\u8282\u70b9\u51fa\u73b0\u4e34\u65f6\u6545\u969c\u65f6\uff0c\u67d0\u4e9bSQL\u53ef\u4ee5\u81ea\u52a8\u4ece\u5907\u7528\u8282\u70b9\u8fdb\u884c\u67e5\u8be2\u3002\u672c\u6587\u4ecb\u7ecd\u8be5\u53c2\u6570gcluster_query_retry\u7684\u4f7f\u7528\u6837\u4f8b\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b0ccef40ad\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2b0ccef40ad\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E5%8F%82%E6%95%B0\" >\u53c2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83\" >\u6d4b\u8bd5\u73af\u5883<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#2%E8%8A%82%E7%82%B9%E9%9B%86%E7%BE%A4\" >2\u8282\u70b9\u96c6\u7fa4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E6%B5%8B%E8%AF%95%E8%A1%A8%E5%92%8C%E6%95%B0%E6%8D%AE\" >\u6d4b\u8bd5\u8868\u548c\u6570\u636e<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E6%9E%84%E9%80%A0%E6%95%85%E9%9A%9C\" >\u6784\u9020\u6545\u969c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E6%B5%8B%E8%AF%95%E6%9F%A5%E8%AF%A2%E9%87%8D%E8%AF%95%E5%8A%9F%E8%83%BD\" >\u6d4b\u8bd5\u67e5\u8be2\u91cd\u8bd5\u529f\u80fd<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E6%9F%A5%E7%9C%8B%E9%9B%86%E7%BE%A4%E6%97%A5%E5%BF%97\" >\u67e5\u770b\u96c6\u7fa4\u65e5\u5fd7<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E5%85%B6%E5%AE%83SQL%E6%B5%8B%E8%AF%95\" >\u5176\u5b83SQL\u6d4b\u8bd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.gbase8.cn\/en\/10624\/#%E5%85%B3%E9%97%AD%E8%87%AA%E5%8A%A8%E9%87%8D%E8%AF%95%E5%8F%82%E6%95%B0%E6%B5%8B%E8%AF%95\" >\u5173\u95ed\u81ea\u52a8\u91cd\u8bd5\u53c2\u6570\u6d4b\u8bd5<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0\"><\/span>\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gcluster_query_retry<\/code><\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u53c2\u6570\u7528\u4e8e\u63a7\u5236\u662f\u5426\u542f\u7528\u67e5\u8be2\u91cd\u8bd5\u673a\u5236\u3002\u91cd\u8bd5\u673a\u5236\u662f\u6307\u5f53\u4e3b\u8282\u70b9\u4e0d\u5de5\u4f5c\u65f6\uff0c\u96c6\u7fa4\u5c06\u53d1\u9001\u67e5\u8be2\u7ed9\u5907\u4efd\u8282\u70b9\u3002\u9ed8\u8ba4\u662f\u4e0d\u542f\u7528\u3002<br>\u53c2\u6570=0\u5173\u95ed\uff1b<br>\u53c2\u6570=1\u542f\u52a8\uff1b<br>\u8be5\u53c2\u6570\u7684\u9ed8\u8ba4\u503c\u662f1\u3002<\/p>\n\n\n\n<p>\u9002\u7528\u4e8e\u9ad8\u53ef\u7528\u5907\u4efd\u67e5\u8be2\u573a\u666f\uff1a<\/p>\n\n\n\n<p>\u96c6\u7fa4\u67e5\u8be2\u4e2d\u67d0\u4e00\u6b65\u9aa4\uff0c\u7531\u4e8e\u8fde\u63a5\u7684\u8282\u70b9offline\u6216\u8005\u5176\u5b83\u4e00\u4e9b\u539f\u56e0\u67e5\u8be2\u5931\u8d25\uff0c\u90a3\u4e48\u6267\u884c\u5668\u4f1a\u5c06\u8be5\u67e5\u8be2\u7531\u4e3b\u8282\u70b9\u8f6c\u5230\u5907\u4efd\u8282\u70b9\u91cd\u65b0\u67e5\u8be2\uff0c\u4f46\u9ad8\u53ef\u7528\u5907\u4efd\u67e5\u8be2\u7684\u524d\u63d0\u4e3a\u8be5\u67e5\u8be2\u6ca1\u6709\u8fdb\u5165\u7ed3\u679c\u5904\u7406\u9636\u6bb5\uff0c\u4e00\u65e6\u8fdb\u5165\u8be5\u9636\u6bb5\uff08\u4f8b\u5982\u5df2\u7ecf\u6709\u7ed3\u679c\u53d1\u9001\u5230\u5ba2\u6237\u7aef\uff09\uff0c\u5219\u4e0d\u4f1a\u542f\u52a8\u9ad8\u53ef\u7528\u5907\u4efd\u67e5\u8be2\uff0c\u800c\u76f4\u63a5\u67e5\u8be2\u62a5\u9519\u3002<\/p>\n\n\n\n<p>\u8be5\u53c2\u6570\u4e0d\u652f\u6301session\u8bbe\u7f6e\uff0c\u53ea\u80fdglobal\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95%E7%8E%AF%E5%A2%83\"><\/span>\u6d4b\u8bd5\u73af\u5883<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2%E8%8A%82%E7%82%B9%E9%9B%86%E7%BE%A4\"><\/span>2\u8282\u70b9\u96c6\u7fa4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&#91;gbase@gbase_rh7_001 gcinstall]$ gcadmin\r\nCLUSTER STATE:         ACTIVE\r\nVIRTUAL CLUSTER MODE:  NORMAL\r\n\r\n=============================================================\r\n|           GBASE COORDINATOR CLUSTER INFORMATION           |\r\n=============================================================\r\n|   NodeName   | IpAddress  | gcware | gcluster | DataState |\r\n-------------------------------------------------------------\r\n| coordinator1 | 10.0.2.101 |  OPEN  |   OPEN   |     0     |\r\n-------------------------------------------------------------\r\n=========================================================================================================\r\n|                                    GBASE DATA CLUSTER INFORMATION                                     |\r\n=========================================================================================================\r\n| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |\r\n---------------------------------------------------------------------------------------------------------\r\n|  node1   |                10.0.2.101                |       1        | OPEN  |    OPEN    |     0     |\r\n---------------------------------------------------------------------------------------------------------\r\n|  node2   |                10.0.2.102                |       1        | OPEN  |    OPEN    |     0     |\r\n---------------------------------------------------------------------------------------------------------\r\n\r\n&#91;gbase@gbase_rh7_001 gcinstall]$ <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95%E8%A1%A8%E5%92%8C%E6%95%B0%E6%8D%AE\"><\/span>\u6d4b\u8bd5\u8868\u548c\u6570\u636e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u6700\u7b80\u5355\u76841\u4e2a\u5217\u7684\u8868\uff0c3\u884c\u6570\u636e<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>\r\ngbase> create database testdb;\r\nQuery OK, 1 row affected (Elapsed: 00:00:00.00)\r\n\r\ngbase> use testdb;\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\r\n\r\ngbase> create table t1(id int);\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.12)\r\n\r\ngbase> insert into t1 values(1),(11),(111);\r\nQuery OK, 3 rows affected (Elapsed: 00:00:00.11)\r\nRecords: 3  Duplicates: 0  Warnings: 0\r\n\r\ngbase> select count(*) from t1;\r\n+----------+\r\n| count(*) |\r\n+----------+\r\n|        3 |\r\n+----------+\r\n1 row in set (Elapsed: 00:00:00.01)\r\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9E%84%E9%80%A0%E6%95%85%E9%9A%9C\"><\/span>\u6784\u9020\u6545\u969c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u624b\u5de5\u8fdb\u5165101\u8282\u70b9\uff0c\u5c06\u5206\u7247\u8868\u5220\u9664\uff0c\u6a21\u62df\u8868\u4e0d\u5b58\u5728\u7684\u6545\u969c<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> ^CAborted\r\n&#91;gbase@gbase_rh7_001 gcinstall]$ gncli\r\n\r\nGBase client 9.5.2.45.58675fc1. Copyright (c) 2004-2022, GBase.  All Rights Reserved.\r\n\r\ngbase> use testdb;\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\r\n\r\ngbase> show tables;\r\n+------------------+\r\n| Tables_in_testdb |\r\n+------------------+\r\n| t1_n1            |\r\n| t1_n2            |\r\n+------------------+\r\n2 rows in set (Elapsed: 00:00:00.00)\r\n\r\ngbase> drop table t1_n1;\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\r\n\r\ngbase> exit\r\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95%E6%9F%A5%E8%AF%A2%E9%87%8D%E8%AF%95%E5%8A%9F%E8%83%BD\"><\/span>\u6d4b\u8bd5\u67e5\u8be2\u91cd\u8bd5\u529f\u80fd<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5728\u96c6\u7fa4\u67e5\u8be2\uff0c\u53d1\u73b0\u7b80\u5355\u7684SQL,\u6bd4\u5982select * , select count(*)\u7b49\u6ca1\u6709\u62a5\u9519<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> use testdb;\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\r\n\r\ngbase> select count(*) from t1;\r\n+----------+\r\n| count(*) |\r\n+----------+\r\n|        3 |\r\n+----------+\r\n1 row in set (Elapsed: 00:00:00.53)\r\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%9F%A5%E7%9C%8B%E9%9B%86%E7%BE%A4%E6%97%A5%E5%BF%97\"><\/span>\u67e5\u770b\u96c6\u7fa4\u65e5\u5fd7<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u96c6\u7fa4\u5c42\u53d1\u73b0\u4e86\u8868\u4e0d\u5b58\u5728\u7684\u60c5\u51b5\uff0c\u5e76\u8bb0\u5f55\u4e86\u65e5\u5fd7\u3002\u96c6\u7fa4\u5185\u90e8\u901a\u8fc7\u91cd\u8bd5\uff0c\u81ea\u52a8\u67e5\u8be2\u4e86\u5907\u7528\u5206\u7247\uff0c\u7ed3\u679c\u6210\u529f\u8fd4\u56de\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&#91;gbase@gbase_rh7_001 gcinstall]$ tail \/opt\/gbase\/gcluster\/log\/gcluster\/express.log  -n 30\r\n\r\u3002\u3002\u3002\u3002\n2022-10-25 09:43:09.050 &#91;SQLDISP]&#91;ERROR]&#91;S:26]&#91;Q:96]&lt;ExecSQL|2567>:Query failed, SessionCtx(0x3df0000) HOST(10.0.2.101:5050->27) reason: Table 'testdb.t1_n1' doesn't exist SQL(SELECT  COUNT(1) FROM `testdb`.`t1_n1`  `vcname000001.testdb.t1`)\r\n&#91;gbase@gbase_rh7_001 gcinstall]$ g<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%85%B6%E5%AE%83SQL%E6%B5%8B%E8%AF%95\"><\/span>\u5176\u5b83SQL\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u53d1\u73b0order by \uff0cgroup \u76ee\u524d\u8fd8\u4e0d\u652f\u6301\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> select * from t1 order by id;\r\nERROR 1708 (HY000): &#91;10.0.2.101:5050](GBA-02AD-0005)Failed to query in gnode:\r\nDETAIL: Table 'testdb.t1_n1' doesn't exist\r\nSQL: CREATE TABLE `gctmpdb`._tmp_1694629898_28_t4_1_1666661350_s AS SELECT \/*10.0.2.101_28_4_2022-10-25_09:44:37*\/ \/*+ TID('43') *\/ `vcname000001.testdb.t1`.`id` AS `c1` FROM `testdb`.`t1_n1` `vcname000001.testdb.t1` LIMIT 0 ;\r\ngbase> <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> select id,count(*) from t1 group by id;\r\nERROR 1708 (HY000): &#91;10.0.2.101:5050](GBA-02AD-0005)Failed to query in gnode:\r\nDETAIL: Table 'testdb.t1_n1' doesn't exist\r\nSQL: CREATE TABLE `gctmpdb`._tmp_rht_1694629898_32_t9_1_1666661350_s_n1 AS SELECT \/*10.0.2.101_32_4_2022-10-25_09:59:39*\/ \/*+ TID('63') *\/ `vcname000001.testdb.t1`.`id` AS `c1`, COUNT(0) AS `c2` FROM `testdb`.`t1_n1` `vcname000001.testdb.t1` GROUP BY `vcname000001.testdb.t1`.`id` LIMIT 0 ;\r\ngbase>\r\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%85%B3%E9%97%AD%E8%87%AA%E5%8A%A8%E9%87%8D%E8%AF%95%E5%8F%82%E6%95%B0%E6%B5%8B%E8%AF%95\"><\/span>\u5173\u95ed\u81ea\u52a8\u91cd\u8bd5\u53c2\u6570\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5173\u95ed\u91cd\u8bd5\u53c2\u6570\u540e\uff0cSQL\u76f4\u63a5\u62a5\u9519\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase> set global  gcluster_query_retry=0;\r\nQuery OK, 0 rows affected (Elapsed: 00:00:00.01)\r\n\r\ngbase> select count(*) from t1;\r\nERROR 1708 (HY000): &#91;10.0.2.101:5050](GBA-02AD-0005)Failed to query in gnode:\r\nDETAIL: Table 'testdb.t1_n1' doesn't exist\r\nSQL: SELECT  COUNT(1) FROM `testdb`.`t1_n1`  `vcname000001.testdb.t1`\r\ngbase>\r\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u652f\u6301\u5728\u67d0\u4e2a\u8282\u70b9\u51fa\u73b0\u4e34\u65f6\u6545\u969c\u65f6\uff0c\u67d0\u4e9bSQL\u53ef\u4ee5\u81ea\u52a8\u4ece\u5907\u7528\u8282\u70b9\u8fdb\u884c\u67e5\u8be2\u3002\u672c\u6587\u4ecb\u7ecd\u8be5\u53c2\u6570gcluster_query_retry\u7684\u4f7f\u7528\u6837\u4f8b\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-10624","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/10624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=10624"}],"version-history":[{"count":2,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/10624\/revisions"}],"predecessor-version":[{"id":10626,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/10624\/revisions\/10626"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=10624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=10624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=10624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}