{"action":"created","issue":{"url":"https://api.github.com/repos/flike/kingshard/issues/472","repository_url":"https://api.github.com/repos/flike/kingshard","labels_url":"https://api.github.com/repos/flike/kingshard/issues/472/labels{/name}","comments_url":"https://api.github.com/repos/flike/kingshard/issues/472/comments","events_url":"https://api.github.com/repos/flike/kingshard/issues/472/events","html_url":"https://github.com/flike/kingshard/issues/472","id":370912379,"node_id":"MDU6SXNzdWUzNzA5MTIzNzk=","number":472,"title":"kingshard应该保证连接池中的连接是无状态的","user":{"login":"chutian52","id":11222742,"node_id":"MDQ6VXNlcjExMjIyNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/11222742?v=4","gravatar_id":"","url":"https://api.github.com/users/chutian52","html_url":"https://github.com/chutian52","followers_url":"https://api.github.com/users/chutian52/followers","following_url":"https://api.github.com/users/chutian52/following{/other_user}","gists_url":"https://api.github.com/users/chutian52/gists{/gist_id}","starred_url":"https://api.github.com/users/chutian52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chutian52/subscriptions","organizations_url":"https://api.github.com/users/chutian52/orgs","repos_url":"https://api.github.com/users/chutian52/repos","events_url":"https://api.github.com/users/chutian52/events{/privacy}","received_events_url":"https://api.github.com/users/chutian52/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-10-17T06:08:28Z","updated_at":"2018-12-03T06:57:47Z","closed_at":null,"author_association":"NONE","body":"**现象**\r\nnode上配置了1个主节点，2个从节点，从节点权重为2,3。\r\n先mysql-cli连接后执行show tables命令，多次执行后得到如下问题\r\n```\r\nmysql> show tables;\r\n+-----------------------------------------------+\r\n| Tables_in_sys                                 |\r\n+-----------------------------------------------+\r\n| host_summary                                  |\r\n| host_summary_by_file_io                       |\r\n| host_summary_by_file_io_type                  |\r\n| host_summary_by_stages                        |\r\n| host_summary_by_statement_latency             |\r\n| host_summary_by_statement_type                |\r\n| innodb_buffer_stats_by_schema                 |\r\n| innodb_buffer_stats_by_table                  |\r\n| innodb_lock_waits                             |\r\n| io_by_thread_by_latency                       |\r\n| io_global_by_file_by_bytes                    |\r\n| io_global_by_file_by_latency                  |\r\n| io_global_by_wait_by_bytes                    |\r\n| io_global_by_wait_by_latency                  |\r\n| latest_file_io                                |\r\n| memory_by_host_by_current_bytes               |\r\n| memory_by_thread_by_current_bytes             |\r\n| memory_by_user_by_current_bytes               |\r\n| memory_global_by_current_bytes                |\r\n| memory_global_total                           |\r\n| metrics                                       |\r\n| processlist                                   |\r\n| ps_check_lost_instrumentation                 |\r\n| schema_auto_increment_columns                 |\r\n| schema_index_statistics                       |\r\n| schema_object_overview                        |\r\n| schema_redundant_indexes                      |\r\n| schema_table_lock_waits                       |\r\n| schema_table_statistics                       |\r\n| schema_table_statistics_with_buffer           |\r\n| schema_tables_with_full_table_scans           |\r\n| schema_unused_indexes                         |\r\n| session                                       |\r\n| session_ssl_status                            |\r\n| statement_analysis                            |\r\n| statements_with_errors_or_warnings            |\r\n| statements_with_full_table_scans              |\r\n| statements_with_runtimes_in_95th_percentile   |\r\n| statements_with_sorting                       |\r\n| statements_with_temp_tables                   |\r\n| sys_config                                    |\r\n| user_summary                                  |\r\n| user_summary_by_file_io                       |\r\n| user_summary_by_file_io_type                  |\r\n| user_summary_by_stages                        |\r\n| user_summary_by_statement_latency             |\r\n| user_summary_by_statement_type                |\r\n| version                                       |\r\n| wait_classes_global_by_avg_latency            |\r\n| wait_classes_global_by_latency                |\r\n| waits_by_host_by_latency                      |\r\n| waits_by_user_by_latency                      |\r\n| waits_global_by_latency                       |\r\n| x$host_summary                                |\r\n| x$host_summary_by_file_io                     |\r\n| x$host_summary_by_file_io_type                |\r\n| x$host_summary_by_stages                      |\r\n| x$host_summary_by_statement_latency           |\r\n| x$host_summary_by_statement_type              |\r\n| x$innodb_buffer_stats_by_schema               |\r\n| x$innodb_buffer_stats_by_table                |\r\n| x$innodb_lock_waits                           |\r\n| x$io_by_thread_by_latency                     |\r\n| x$io_global_by_file_by_bytes                  |\r\n| x$io_global_by_file_by_latency                |\r\n| x$io_global_by_wait_by_bytes                  |\r\n| x$io_global_by_wait_by_latency                |\r\n| x$latest_file_io                              |\r\n| x$memory_by_host_by_current_bytes             |\r\n| x$memory_by_thread_by_current_bytes           |\r\n| x$memory_by_user_by_current_bytes             |\r\n| x$memory_global_by_current_bytes              |\r\n| x$memory_global_total                         |\r\n| x$processlist                                 |\r\n| x$ps_digest_95th_percentile_by_avg_us         |\r\n| x$ps_digest_avg_latency_distribution          |\r\n| x$ps_schema_table_statistics_io               |\r\n| x$schema_flattened_keys                       |\r\n| x$schema_index_statistics                     |\r\n| x$schema_table_lock_waits                     |\r\n| x$schema_table_statistics                     |\r\n| x$schema_table_statistics_with_buffer         |\r\n| x$schema_tables_with_full_table_scans         |\r\n| x$session                                     |\r\n| x$statement_analysis                          |\r\n| x$statements_with_errors_or_warnings          |\r\n| x$statements_with_full_table_scans            |\r\n| x$statements_with_runtimes_in_95th_percentile |\r\n| x$statements_with_sorting                     |\r\n| x$statements_with_temp_tables                 |\r\n| x$user_summary                                |\r\n| x$user_summary_by_file_io                     |\r\n| x$user_summary_by_file_io_type                |\r\n| x$user_summary_by_stages                      |\r\n| x$user_summary_by_statement_latency           |\r\n| x$user_summary_by_statement_type              |\r\n| x$wait_classes_global_by_avg_latency          |\r\n| x$wait_classes_global_by_latency              |\r\n| x$waits_by_host_by_latency                    |\r\n| x$waits_by_user_by_latency                    |\r\n| x$waits_global_by_latency                     |\r\n+-----------------------------------------------+\r\n101 rows in set (0.01 sec)\r\n\r\nmysql> show tables;\r\n+---------------------------------+\r\n| Tables_in_starter_shopping_cart |\r\n+---------------------------------+\r\n| product_city_mapping_bak        |\r\n| schema_version                  |\r\n| shopping_cart                   |\r\n| shopping_cart_config            |\r\n| shopping_cart_migration         |\r\n+---------------------------------+\r\n5 rows in set (0.01 sec)\r\n\r\nmysql> show tables;\r\n+---------------------------------+\r\n| Tables_in_starter_shopping_cart |\r\n+---------------------------------+\r\n| product_city_mapping_bak        |\r\n| schema_version                  |\r\n| shopping_cart                   |\r\n| shopping_cart_config            |\r\n| shopping_cart_migration         |\r\n+---------------------------------+\r\n5 rows in set (0.01 sec)\r\n\r\nmysql> show tables;\r\nERROR 1046 (3D000): No database selected\r\nmysql> show tables;\r\nERROR 1046 (3D000): No database selected\r\nmysql>\r\n```\r\n在上述测试中，并未开启use [database]命令。\r\n个人推测是由于kingshard并没有清空与MySQL Server的状态，导致了从连接池中获取连接的时候没能正确的执行正确的指令。"},"comment":{"url":"https://api.github.com/repos/flike/kingshard/issues/comments/443607844","html_url":"https://github.com/flike/kingshard/issues/472#issuecomment-443607844","issue_url":"https://api.github.com/repos/flike/kingshard/issues/472","id":443607844,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzYwNzg0NA==","user":{"login":"chutian52","id":11222742,"node_id":"MDQ6VXNlcjExMjIyNzQy","avatar_url":"https://avatars1.githubusercontent.com/u/11222742?v=4","gravatar_id":"","url":"https://api.github.com/users/chutian52","html_url":"https://github.com/chutian52","followers_url":"https://api.github.com/users/chutian52/followers","following_url":"https://api.github.com/users/chutian52/following{/other_user}","gists_url":"https://api.github.com/users/chutian52/gists{/gist_id}","starred_url":"https://api.github.com/users/chutian52/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chutian52/subscriptions","organizations_url":"https://api.github.com/users/chutian52/orgs","repos_url":"https://api.github.com/users/chutian52/repos","events_url":"https://api.github.com/users/chutian52/events{/privacy}","received_events_url":"https://api.github.com/users/chutian52/received_events","type":"User","site_admin":false},"created_at":"2018-12-03T06:57:47Z","updated_at":"2018-12-03T06:57:47Z","author_association":"NONE","body":"@flike 这种针对默认不设置db或一些工具类可能有用。但对于应用程序而言，效率确实低下，也是没必要的。\r\n我个人觉得这个连接池可以适当的优化下，可以针对每个schema设置一个连接池，之后再合理设置担保机制，这样不用每次都usedb"}}
{"actor":{"display_login":"chutian52"}}