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 2023/01/17 06:01:20 UTC

[GitHub] [shardingsphere] sandynz opened a new issue, #23603: Drop table failed when table name doesn't match logical table name in sharding rule case 1

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

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master, 8c58db88d879428ec80d98ae04ff4661d7dde0af
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   proxy, PostgreSQL backend
   
   ### Expected behavior
   Drop table succeed
   
   ### Actual behavior
   Drop table failed
   
   ```
   sharding_db=> CREATE SHARDING TABLE RULE T_ORDER(
   sharding_db(> STORAGE_UNITS(ds_2,ds_3,ds_4),
   sharding_db(> SHARDING_COLUMN=order_id,
   sharding_db(> TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="6")),
   sharding_db(> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME="snowflake"))
   sharding_db(> );
   SUCCESS
   sharding_db=> CREATE TABLE t_order (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
   CREATE TABLE
   sharding_db=> select * from t_order;
    order_id | user_id | status
   ----------+---------+--------
   (0 rows)
   
   sharding_db=> drop table t_order;
   ERROR:  org.postgresql.util.PSQLException
   ```
   
   No exception stack trace in proxy log, after debug, the exception is:
   ```
   org.apache.shardingsphere.dialect.exception.syntax.table.NoSuchTableException
   	at org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator.validateTableExist(ShardingDDLStatementValidator.java:64)
   	at org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl.ShardingDropTableStatementValidator.preValidate(ShardingDropTableStatementValidator.java:56)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.lambda$createRouteContext$0(ShardingSQLRouter.java:55)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:55)
   	at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:46)
   	at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:69)
   	at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:55)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.route(KernelProcessor.java:59)
   	at org.apache.shardingsphere.infra.context.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:51)
   	at org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicationEngine.execute(DatabaseCommunicationEngine.java:170)
   	at org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor.execute(PostgreSQLComQueryExecutor.java:77)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.executeCommand(CommandExecutorTask.java:110)
   	at org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask.run(CommandExecutorTask.java:77)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   	at java.lang.Thread.run(Thread.java:748)
   ```
   
   ### Reason analyze (If you can)
   
   There's no table metadata in schema:
   ![WX20230117-132321@2x](https://user-images.githubusercontent.com/42492540/212818533-4297ee22-c267-4064-af5e-553a795f5c65.png)
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   
   `server.yaml`
   ```
   mode:
     type: Cluster
     repository:
       type: ZooKeeper
       props:
         namespace: governance_ds
         server-lists: localhost:2181
         retryIntervalMilliseconds: 500
         timeToLiveSeconds: 60
         maxRetries: 3
         operationTimeoutMilliseconds: 500
   
   authority:
     users:
       - user: root@%
         password: root
       - user: sharding
         password: sharding
     privilege:
       type: ALL_PERMITTED
   
   #transaction:
   #  defaultType: XA
   #  providerType: Atomikos
   
   sqlParser:
     sqlCommentParseEnabled: false
     sqlStatementCache:
       initialCapacity: 2000
       maximumSize: 65535
     parseTreeCache:
       initialCapacity: 128
       maximumSize: 1024
   
   #cdc:
   #  enabled: false
   #  port: 33071
   
   props:
     max-connections-size-per-query: 1
     kernel-executor-size: 16  # Infinite by default.
     proxy-frontend-flush-threshold: 128  # The default value is 128.
     proxy-hint-enabled: false
     sql-show: false
     check-table-metadata-enabled: false
       # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
       # The default value is -1, which means set the minimum value for different JDBC drivers.
     proxy-backend-query-fetch-size: -1
     proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
       # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
       # and block other clients if client connections are more than `proxy-frontend-executor-size`, especially executing slow SQL.
     proxy-backend-executor-suitable: OLAP
     proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
       # Available sql federation type: NONE (default), ORIGINAL, ADVANCED
     sql-federation-type: NONE
     proxy-mysql-default-version: 5.7.22 # In the absence of schema name, the default version will be used.
     proxy-default-port: 3307 # Proxy default port.
     proxy-netty-backlog: 1024 # Proxy netty backlog.
     proxy-frontend-database-protocol-type: PostgreSQL
   ```
   
   Execute SQLs in PostgreSQL:
   ```
   DROP DATABASE IF EXISTS migration_ds_10;
   CREATE DATABASE migration_ds_10;
   
   DROP DATABASE IF EXISTS migration_ds_11;
   CREATE DATABASE migration_ds_11;
   
   DROP DATABASE IF EXISTS migration_ds_12;
   CREATE DATABASE migration_ds_12;
   ```
   
   Execute DistSQLs in proxy:
   ```
   CREATE SHARDING TABLE RULE T_ORDER(
   STORAGE_UNITS(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"))
   );
   
   CREATE TABLE t_order (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
   
   SELECT * FROM t_order;
   
   DROP TABLE t_order;
   DROP TABLE T_ORDER;
   ```
   
   ### 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] zhaojinchao95 commented on issue #23603: Drop table failed when table name doesn't match logical table name in sharding rule case 1

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on issue #23603:
URL: https://github.com/apache/shardingsphere/issues/23603#issuecomment-1386467635

   @sandynz Hi, maybe it's about PG case matters. Such as :
   
   `SELECT table_name FROM information_schema.role_table_grants WHERE table_name IN ('t_order_0');` this sql are some response from PG.
   
   `SELECT table_name FROM information_schema.role_table_grants WHERE table_name IN ('T_ORDER_0');` this sql are not some response from PG.
   
   <img width="851" alt="image" src="https://user-images.githubusercontent.com/33742097/213083491-b41bcb2d-7383-4660-8802-92cc5966052f.png">
   


-- 
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