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/05/06 08:49:28 UTC

[GitHub] [shardingsphere] sandynz opened a new issue, #17380: Create table failed in ShardingSphereDataSource immediately after creating schema

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

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   master branch, commit 01af864c821621ea5e48864e77c4cedcc378b1a1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   Proxy
   
   ### Expected behavior
   Not exception thrown.
   
   ### Actual behavior
   Create table failed in ShardingSphereDataSource after creating schema:
   ```
   [INFO ] 2022-05-06 16:24:34.458 [elasticjob-0130317c30317c3154327c7363616c696e675f6462-2] o.a.s.d.p.c.p.d.AbstractDataSourcePreparer - execute target table sql: CREATE TABLE IF NOT EXISTS schema1.t_order(order_id integer NOT NULL,user_id integer NOT NULL,status character varying(45),PRIMARY KEY(order_id))
   [ERROR] 2022-05-06 16:24:34.607 [elasticjob-0130317c30317c3154327c7363616c696e675f6462-2] o.a.s.d.p.s.r.RuleAlteredJob - job prepare failed, 0130317c30317c3154327c7363616c696e675f6462-1
   java.lang.NullPointerException: null
   	at org.apache.shardingsphere.infra.context.refresher.type.CreateTableStatementSchemaRefresher.lambda$refresh$2(CreateTableStatementSchemaRefresher.java:61)
   	at java.util.Optional.ifPresent(Optional.java:159)
   	at org.apache.shardingsphere.infra.context.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:60)
   	at org.apache.shardingsphere.infra.context.refresher.type.CreateTableStatementSchemaRefresher.refresh(CreateTableStatementSchemaRefresher.java:45)
   	at org.apache.shardingsphere.infra.context.refresher.MetaDataRefreshEngine.refresh(MetaDataRefreshEngine.java:69)
   	at org.apache.shardingsphere.driver.executor.DriverJDBCExecutor.refreshMetaData(DriverJDBCExecutor.java:158)
   	at org.apache.shardingsphere.driver.executor.DriverJDBCExecutor.doExecute(DriverJDBCExecutor.java:153)
   	at org.apache.shardingsphere.driver.executor.DriverJDBCExecutor.execute(DriverJDBCExecutor.java:141)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute(ShardingSphereStatement.java:414)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute0(ShardingSphereStatement.java:438)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute(ShardingSphereStatement.java:356)
   	at org.apache.shardingsphere.data.pipeline.core.prepare.datasource.AbstractDataSourcePreparer.executeTargetTableSQL(AbstractDataSourcePreparer.java:111)
   	at org.apache.shardingsphere.data.pipeline.postgresql.prepare.datasource.PostgreSQLDataSourcePreparer.prepareTargetTables(PostgreSQLDataSourcePreparer.java:91)
   	at org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepareTarget(RuleAlteredJobPreparer.java:140)
   	at org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepareAndCheckTarget(RuleAlteredJobPreparer.java:121)
   	at org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepareAndCheckTargetWithLock(RuleAlteredJobPreparer.java:101)
   	at org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJobPreparer.prepare(RuleAlteredJobPreparer.java:81)
   	at org.apache.shardingsphere.data.pipeline.scenario.rulealtered.RuleAlteredJob.execute(RuleAlteredJob.java:51)
   ```
   
   Another exception after creating schema in ShardingSphereDataSource:
   ```
   [ERROR] 2022-05-06 16:24:34.344 [Curator-SafeNotifyService-0] o.a.c.f.l.MappingListenerManager - Listener (org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2@7affee54) threw an exception
   java.lang.RuntimeException: java.lang.NullPointerException
   	at org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.sendEvent(TreeCacheListenerWrapper.java:75)
   	at org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.event(TreeCacheListenerWrapper.java:42)
   	at org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.lambda$event$0(CuratorCacheListenerBuilderImpl.java:149)
   	at java.util.ArrayList.forEach(ArrayList.java:1259)
   	at org.apache.curator.framework.recipes.cache.CuratorCacheListenerBuilderImpl$2.event(CuratorCacheListenerBuilderImpl.java:149)
   	at org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$putStorage$7(CuratorCacheImpl.java:279)
   	at org.apache.curator.framework.listen.MappingListenerManager.lambda$forEach$0(MappingListenerManager.java:92)
   	at org.apache.curator.framework.listen.MappingListenerManager.forEach(MappingListenerManager.java:89)
   	at org.apache.curator.framework.listen.StandardListenerManager.forEach(StandardListenerManager.java:89)
   	at org.apache.curator.framework.recipes.cache.CuratorCacheImpl.lambda$callListeners$10(CuratorCacheImpl.java:293)
   	at java.util.concurrent.CompletableFuture$AsyncRun.run$$$capture(CompletableFuture.java:1640)
   	at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java)
   	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)
   Caused by: java.lang.NullPointerException: null
   	at java.util.Objects.requireNonNull(Objects.java:203)
   	at java.util.Optional.<init>(Optional.java:96)
   	at java.util.Optional.of(Optional.java:108)
   	at org.apache.shardingsphere.mode.metadata.persist.node.DatabaseMetaDataNode.getSchemaNameBySchemaPath(DatabaseMetaDataNode.java:182)
   	at org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.watcher.MetaDataChangedWatcher.isTableMetaDataChanged(MetaDataChangedWatcher.java:95)
   	at org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.metadata.watcher.MetaDataChangedWatcher.createGovernanceEvent(MetaDataChangedWatcher.java:77)
   	at org.apache.shardingsphere.mode.manager.cluster.coordinator.registry.GovernanceWatcherFactory.lambda$watch$0(GovernanceWatcherFactory.java:55)
   	at org.apache.shardingsphere.mode.repository.cluster.zookeeper.CuratorZookeeperRepository.lambda$watch$0(CuratorZookeeperRepository.java:247)
   	at org.apache.curator.framework.recipes.cache.TreeCacheListenerWrapper.sendEvent(TreeCacheListenerWrapper.java:71)
   	... 14 common frames omitted
   ```
   
   ### Reason analyze (If you can)
   Schema metadata does not exist, but it exists after some time.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   1. new ShardingSphereDataSource
   2. create schema1
   3. create table in schema1
   
   ### 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] zjcnb closed issue #17380: Create table failed in ShardingSphereDataSource immediately after creating schema

Posted by GitBox <gi...@apache.org>.
zjcnb closed issue #17380: Create table failed in ShardingSphereDataSource immediately after creating schema
URL: https://github.com/apache/shardingsphere/issues/17380


-- 
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] sandynz commented on issue #17380: Create table failed in ShardingSphereDataSource immediately after creating schema

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

   Seems `PostgreSQLDDLStatementSQLVisitor.visitCreateSchema` doesn't filter quoted character.
   
   ```
       public ASTNode visitCreateSchema(final CreateSchemaContext ctx) {
           PostgreSQLCreateSchemaStatement result = new PostgreSQLCreateSchemaStatement();
           if (null != ctx.createSchemaClauses().colId()) {
               result.setSchemaName(ctx.createSchemaClauses().colId().getText());
           }
   ```
   
   


-- 
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] strongduanmu commented on issue #17380: Create table failed in ShardingSphereDataSource immediately after creating schema

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

   @sandynz Thank you for your feedback, I will optimize this issue.


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