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 2021/08/24 14:46:33 UTC

[GitHub] [shardingsphere] rfscouto opened a new issue #11990: Insert through shardingsphere gives null pointer exception

rfscouto opened a new issue #11990:
URL: https://github.com/apache/shardingsphere/issues/11990


   Posting this as a question, as I am not sure if this is a bug or bad usage on my part.
   
   I am currently using the latest master, and also liquibase (4.4.2).
   I have the following properties:
    ```
   SPRING_JPA_DATABASE=POSTGRESQL
         - SPRING_JPA_HIBERNATE_DDL-AUTO=update
         - SPRING_JPA_DATABASE-PLATFORM=org.hibernate.dialect.PostgreSQL9Dialect
         - SPRING_JPA_PROPERTIES_HIBERNATE_TEMP_USE_JDBC_METADATA_DEFAULTS=false
         - SPRING_JPA_PROPERTIES_HIBERNATE_TEMP_USE_JDBC_LOB_NON_CONTEXTUAL_CREATION=true
         - SPRING_JPA_PROPERTIES_OPEN-IN-VIEW=false
         - SPRING_LIQUIBASE_DEFAULT-SCHEMA=public
         - SPRING_SHARDINGSPHERE_ENABLED=false
         - SPRING_SHARDINGSPHERE_ALTERNATEIMPL=true
         - SPRING_SHARDINGSPHERE_SCHEMANAME=public
         - SPRING_SHARDINGSPHERE_DATASOURCE_NAMES=testdatasource
         - SPRING_SHARDINGSPHERE_DATASOURCE_testdatasource_TYPE=com.zaxxer.hikari.HikariDataSource
         - SPRING_SHARDINGSPHERE_DATASOURCE_testdatasource_DRIVER-CLASS-NAME=org.postgresql.Driver
         - SPRING_SHARDINGSPHERE_DATASOURCE_testdatasource_JDBC-URL=${DATASOURCE_URL}
         - SPRING_SHARDINGSPHERE_DATASOURCE_testdatasource_URL=${DATASOURCE_URL}
         - SPRING_SHARDINGSPHERE_DATASOURCE_testdatasource_USERNAME=${DATASOURCE_USERNAME}
         - SPRING_SHARDINGSPHERE_DATASOURCE_testdatasource_PASSWORD=${DATASOURCE_PASSWORD}
         - SPRING_SHARDINGSPHERE_DATASOURCE_testdatasource_SCHEMA=public
         - SPRING_SHARDINGSPHERE_SHARDING_TABLES_MAIN_ACTUAL-DATA-NODES=testdatasource.main$->{0..1}
         - SPRING_SHARDINGSPHERE_SHARDING_TABLES_MAIN_TABLE-STRATEGY_INLINE_SHARDING-COLUMN=id
         - SPRING_SHARDINGSPHERE_SHARDING_TABLES_MAIN_TABLE-STRATEGY_INLINE_ALGORITHM-EXPRESSION=main$->{id}
         - SPRING_SHARDINGSPHERE_SHARDING_TABLES_MAIN_KEY-GENERATOR_COLUMN=id
         - SPRING_SHARDINGSPHERE_SHARDING_TABLES_MAIN_KEY-GENERATOR_TYPE=UUID
         
   ```
   Liquibase, as part of it's initial setup, is trying to insert a row in `databasechangeloglock` to start performing changes.
   However, the insert fails with an exception:
   
   ```
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.LockException: liquibase.exception.DatabaseException: null [Failed SQL: INSERT INTO public.databasechangeloglock (ID, LOCKED) VALUES (1, FALSE)]
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
   	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
   	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108)
   	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
   	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
   	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
   	at com.main(main.java:15)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
   	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
   	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
   	at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
   	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
   Caused by: liquibase.exception.LockException: liquibase.exception.DatabaseException: null [Failed SQL: INSERT INTO public.databasechangeloglock (ID, LOCKED) VALUES (1, FALSE)]
   	at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:293)
   	at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:211)
   	at liquibase.Liquibase.lambda$update$1(Liquibase.java:214)
   	at liquibase.Scope.lambda$child$0(Scope.java:166)
   	at liquibase.Scope.child(Scope.java:175)
   	at liquibase.Scope.child(Scope.java:165)
   	at liquibase.Scope.child(Scope.java:144)
   	at liquibase.Liquibase.runInScope(Liquibase.java:2404)
   	at liquibase.Liquibase.update(Liquibase.java:211)
   	at liquibase.Liquibase.update(Liquibase.java:197)
   	at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314)
   	at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
   	... 25 common frames omitted
   Caused by: liquibase.exception.DatabaseException: null [Failed SQL: INSERT INTO public.databasechangeloglock (ID, LOCKED) VALUES (1, FALSE)]
   	at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:393)
   	at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:82)
   	at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:150)
   	at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:134)
   	at liquibase.lockservice.StandardLockService.init(StandardLockService.java:126)
   	at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:250)
   	... 38 common frames omitted
   Caused by: java.lang.NullPointerException: null
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLStatementSQLVisitor.visitInsertTarget(PostgreSQLStatementSQLVisitor.java:563)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLStatementSQLVisitor.visitInsertTarget(PostgreSQLStatementSQLVisitor.java:173)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$InsertTargetContext.accept(PostgreSQLStatementParser.java:1386)
   	at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLStatementSQLVisitor.visitInsert(PostgreSQLStatementSQLVisitor.java:551)
   	at org.apache.shardingsphere.sql.parser.postgresql.visitor.statement.impl.PostgreSQLStatementSQLVisitor.visitInsert(PostgreSQLStatementSQLVisitor.java:173)
   	at org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser$InsertContext.accept(PostgreSQLStatementParser.java:1309)
   	at org.apache.shardingsphere.sql.parser.api.SQLVisitorEngine.visit(SQLVisitorEngine.java:49)
   	at org.apache.shardingsphere.infra.parser.sql.SQLStatementParserExecutor.parse(SQLStatementParserExecutor.java:47)
   	at org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine.parse(SQLStatementParserEngine.java:48)
   	at org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine.parse0(ShardingSphereSQLParserEngine.java:67)
   	at org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine.parse(ShardingSphereSQLParserEngine.java:56)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.createLogicSQL(ShardingSphereStatement.java:364)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.createExecutionContext(ShardingSphereStatement.java:372)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute0(ShardingSphereStatement.java:336)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute(ShardingSphereStatement.java:292)
   	at io.opentracing.contrib.jdbc.TracingStatement.execute(TracingStatement.java:148)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
   	at io.opentracing.contrib.common.WrapperProxy$1.invoke(WrapperProxy.java:73)
   	at com.sun.proxy.$Proxy207.execute(Unknown Source)
   	at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:389)
   	... 43 common frames omitted
   ```
   
   <img width="1099" alt="Screenshot 2021-08-24 at 16 28 17" src="https://user-images.githubusercontent.com/2998542/130636918-e3a23aa0-b26c-4c7f-bca0-b4a6d225039b.png">
   Upon further debugging I noticed the colId (as per image above) is null.
   At this point this parsing is very unfamiliar to me.
   
   Any tips?
   
   


-- 
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] rfscouto commented on issue #11990: Insert through shardingsphere gives null pointer exception

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


   Using the current master version, so, between 5.0.0-beta and 5.0.0-RC1.
   Which mode prefix do you mean?


-- 
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 #11990: Parser cannot handle SQL statements prefixed with schema

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


   Sorry for later reply. @tuichenchuxin Can you help check 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



[GitHub] [shardingsphere] tuichenchuxin commented on issue #11990: Parser cannot handle SQL statements prefixed with schema

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


   @rfscouto After this [pr](https://github.com/apache/shardingsphere/pull/12787) merged, insert with schema will be fixed.


-- 
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] rfscouto edited a comment on issue #11990: Insert through shardingsphere gives null pointer exception

Posted by GitBox <gi...@apache.org>.
rfscouto edited a comment on issue #11990:
URL: https://github.com/apache/shardingsphere/issues/11990#issuecomment-904852211


   Using the current master version, so, between 5.0.0-beta and 5.0.0-RC1.
   Which mode prefix do you mean? the schema?


-- 
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 closed issue #11990: Parser cannot handle SQL statements prefixed with schema

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #11990:
URL: https://github.com/apache/shardingsphere/issues/11990


   


-- 
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] rfscouto edited a comment on issue #11990: Insert through shardingsphere gives null pointer exception

Posted by GitBox <gi...@apache.org>.
rfscouto edited a comment on issue #11990:
URL: https://github.com/apache/shardingsphere/issues/11990#issuecomment-904852211


   Using the current master version, so, between 5.0.0-beta and 5.0.0-RC1.
   Which mode prefix do you mean? the schema? how would I do that? is it a configuration?
   
   Update: just tested fully on 5.0.0-beta. Same error.


-- 
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] rfscouto edited a comment on issue #11990: Insert through shardingsphere gives null pointer exception

Posted by GitBox <gi...@apache.org>.
rfscouto edited a comment on issue #11990:
URL: https://github.com/apache/shardingsphere/issues/11990#issuecomment-904852211


   Using the current master version, so, between 5.0.0-beta and 5.0.0-RC1.
   Which mode prefix do you mean? the schema?
   
   Update: just tested fully on 5.0.0-beta. Same error.


-- 
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 closed issue #11990: Parser cannot handle SQL statements prefixed with schema

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #11990:
URL: https://github.com/apache/shardingsphere/issues/11990


   


-- 
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] rfscouto commented on issue #11990: Insert through shardingsphere gives null pointer exception

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


   I noticed that if I omit the property for default schema for liquibase, application startup fails, because liquibase has no default schema. 
   If I do have the property, and remove the "public." from the queries being issued by Liquibase, then Shardingsphere doesn't throw the null pointer exception.
   I can try to make liquibase stop outputting the schema, but I guess ShardingSphere should be able to parse the schema too, no?


-- 
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] avalon5666 commented on issue #11990: Insert through shardingsphere gives null pointer exception

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


   Which version are you using?
   And try to remove mode prefix, only use table name.


-- 
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] tuichenchuxin commented on issue #11990: Parser cannot handle SQL statements prefixed with schema

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


   @rfscouto After this [pr](https://github.com/apache/shardingsphere/pull/12787) merged, insert with schema will be fixed.


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