You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/09/08 09:39:57 UTC

[GitHub] [shardingsphere] sandynz opened a new issue, #20881: Query MySQL system variable failed in empty database when there is another database contains data source

sandynz opened a new issue, #20881:
URL: https://github.com/apache/shardingsphere/issues/20881

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master branch, commit 23c502ccb4b8b207c1fa31b1644da6d3520f2c5e
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   proxy
   
   ### Expected behavior
   Following query works:
   ```
   /* mysql-connector-java-5.1.47 ( Revision: fe1903b1ecb4a96a917f7ed3190d80c049b1de29 ) */SELECT  @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@collation_server AS collation_server, @@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_buffer_length AS net_buffer_length, @@net_write_timeout AS net_write_timeout, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@transaction_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout;
   ```
   
   Simplied one:
   ```
   SELECT @@session.auto_increment_increment;
   ```
   
   ### Actual behavior
   
   There're 2 databases:
   - scaling_nomig : with full data source and rules configured
   - sharding_db : empty
   
   1. No database is selected, it works
   2. If there's only empty database and selected, it works
   3. Select empty database, it does NOT work
   
   ```
   mysql> SELECT  @@session.auto_increment_increment;
   +------------------------------------+
   | @@session.auto_increment_increment |
   +------------------------------------+
   | 1                                  |
   +------------------------------------+
   1 row in set (0.01 sec)
   
   mysql> use sharding_db
   Database changed
   mysql> show sharding table rules;
   Empty set (0.95 sec)
   
   mysql> SELECT  @@session.auto_increment_increment;
   ERROR 11003 (42000): Rule does not exist
   ```
   
   `Rule does not exist` is from RuleNotExistedException, related code: UnicastDatabaseBackendHandler.execute
   ```
       public ResponseHeader execute() throws SQLException {
           String originDatabase = connectionSession.getDefaultDatabaseName();
           String databaseName = null == originDatabase ? getFirstDatabaseName() : originDatabase;
           if (!ProxyContext.getInstance().getDatabase(databaseName).containsDataSource()) {
               throw new RuleNotExistedException();
           }
   ...
   ```
   
   ### Reason analyze (If you can)
   
   It might be affected by MySQLAdminExecutorCreator.hasNoResource():
   ```
       private boolean hasNoResource() {
           Collection<String> databaseNames = ProxyContext.getInstance().getAllDatabaseNames();
           if (databaseNames.isEmpty()) {
               return true;
           }
           for (String each : databaseNames) {
               if (ProxyContext.getInstance().getDatabase(each).containsDataSource()) {
                   return false;
               }
           }
           return true;
       }
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   SQL log:
   ```
   mysql> show databases;
   +--------------------+
   | schema_name        |
   +--------------------+
   | information_schema |
   | performance_schema |
   | sys                |
   | mysql              |
   +--------------------+
   4 rows in set (0.02 sec)
   
   mysql> SELECT @@session.auto_increment_increment;
   +------------------------------------+
   | @@session.auto_increment_increment |
   +------------------------------------+
   |                                    |
   +------------------------------------+
   1 row in set (0.06 sec)
   
   mysql> create database sharding_db;
   Query OK, 0 rows affected (0.09 sec)
   
   mysql> use sharding_db
   Database changed
   mysql> SELECT @@session.auto_increment_increment;
   +------------------------------------+
   | @@session.auto_increment_increment |
   +------------------------------------+
   |                                    |
   +------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> create database scaling_nomig;
   Query OK, 0 rows affected (0.01 sec)
   
   mysql> use scaling_nomig
   Database changed
   mysql> ADD RESOURCE ds_2 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/migration_ds_10?serverTimezone=UTC&useSSL=false",
       ->     USER="root",
       PASSWORD="root",
       PROPERTIES("minPoolSize"="1","maxPoolSize"="20","idleTimeout"="60000")
   ), ds_3 (
       URL="jdbc:mysql://127.0.0.1:3306/migration_ds_11?serverTimezone=UTC&useSSL=false",
       USER="root",
       PASSWORD="root",
       PROPERTIES("minPoolSize"="1","maxPoolSize"="20","idleTimeout"="60000")
   ), ds_4 (
       URL="jdbc:mysql://127.0.0.1:3306/migration_ds_12?serverTimezone=UTC&useSSL=false",
       USER="root",
       PASSWORD="root",
       PROPERTIES("minPoolSize"="1","maxPoolSize"="20","idleTimeout"="60000")
   );    USER="root",
       ->     PASSWORD="root",
       ->     PROPERTIES("minPoolSize"="1","maxPoolSize"="20","idleTimeout"="60000")
       -> ), ds_3 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/migration_ds_11?serverTimezone=UTC&useSSL=false",
       ->     USER="root",
       ->     PASSWORD="root",
       ->     PROPERTIES("minPoolSize"="1","maxPoolSize"="20","idleTimeout"="60000")
       -> ), ds_4 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/migration_ds_12?serverTimezone=UTC&useSSL=false",
       ->     USER="root",
       ->     PASSWORD="root",
       ->     PROPERTIES("minPoolSize"="1","maxPoolSize"="20","idleTimeout"="60000")
       -> );
   Query OK, 0 rows affected (1.37 sec)
   
   mysql> CREATE SHARDING TABLE RULE t_order(
       -> RESOURCES(ds_2,ds_3,ds_4),
       -> SHARDING_COLUMN=order_id,
       -> TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="6")),
       -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME="snowflake"))
       -> );
   Query OK, 0 rows affected (0.50 sec)
   
   mysql> SELECT @@session.auto_increment_increment;
   +------------------------------------+
   | @@session.auto_increment_increment |
   +------------------------------------+
   |                                  1 |
   +------------------------------------+
   1 row in set (0.02 sec)
   
   mysql> use sharding_db
   Database changed
   mysql> SELECT @@session.auto_increment_increment;
   ERROR 11003 (42000): Rule does not exist
   ```
   
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] boyjoy1127 commented on issue #20881: Query MySQL system variable failed in empty database when there is another database contains data source

Posted by "boyjoy1127 (via GitHub)" <gi...@apache.org>.
boyjoy1127 commented on issue #20881:
URL: https://github.com/apache/shardingsphere/issues/20881#issuecomment-1585976677

   Will this issue be completed before June 15 which is the final date of version 5.4.0?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on issue #20881: Query MySQL system variable failed in empty database when there is another database contains data source

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN commented on issue #20881:
URL: https://github.com/apache/shardingsphere/issues/20881#issuecomment-1585977024

   I think this is already fixed by #25265.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN closed issue #20881: Query MySQL system variable failed in empty database when there is another database contains data source

Posted by "TeslaCN (via GitHub)" <gi...@apache.org>.
TeslaCN closed issue #20881: Query MySQL system variable failed in empty database when there is another database contains data source
URL: https://github.com/apache/shardingsphere/issues/20881


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] commented on issue #20881: Query MySQL system variable failed in empty database when there is another database contains data source

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #20881:
URL: https://github.com/apache/shardingsphere/issues/20881#issuecomment-1272348504

   Hello , this issue has not received a reply for several days.
   This issue is supposed to be closed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] closed issue #20881: Query MySQL system variable failed in empty database when there is another database contains data source

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #20881: Query MySQL system variable failed in empty database when there is another database contains data source
URL: https://github.com/apache/shardingsphere/issues/20881


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org