You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "XinShepherd (via GitHub)" <gi...@apache.org> on 2023/02/21 08:24:54 UTC

[GitHub] [shardingsphere] XinShepherd opened a new issue, #24276: When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException

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

   # Bug Report
   Which version of ShardingSphere did you use?
   5.2.1
   
   ## Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ## H2 version
   ```
         <dependency>
           <groupId>com.h2database</groupId>
           <artifactId>h2</artifactId>
           <version>1.4.200</version>
         </dependency>
   ```
   ## Expected behavior
   H2 Dialect load table meta data successfully
   
   ## Actual behavior
   Dialect load table meta data error.
   
   the exception is:
   
   ```
   2023-02-21 15:25:38.864  INFO 9167 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
   2023-02-21 15:25:38.867  INFO 9167 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
   2023-02-21 15:27:14.538 ERROR 9167 --- [           main] a.s.i.m.d.s.l.SchemaMetaDataLoaderEngine : Dialect load table meta data error.
   
   java.sql.SQLException: Unknown exception: java.lang.NullPointerException
   	at org.apache.shardingsphere.infra.util.exception.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:54) ~[shardingsphere-infra-util-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.schema.loader.SchemaMetaDataLoaderEngine.loadByDialect(SchemaMetaDataLoaderEngine.java:99) ~[shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.schema.loader.SchemaMetaDataLoaderEngine.load(SchemaMetaDataLoaderEngine.java:65) ~[shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.loadSchemas(GenericSchemaBuilder.java:95) [shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.build(GenericSchemaBuilder.java:78) [shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.build(GenericSchemaBuilder.java:66) [shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:89) [shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.createGenericDatabases(ShardingSphereDatabasesFactory.java:81) [shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:69) [shardingsphere-infra-common-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:91) [shardingsphere-mode-core-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:69) [shardingsphere-mode-core-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:49) [shardingsphere-standalone-mode-core-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:76) [shardingsphere-jdbc-core-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:64) [shardingsphere-jdbc-core-5.2.1.jar:5.2.1]
   	at org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:93) [shardingsphere-jdbc-core-5.2.1.jar:5.2.1]
   ```
   
   And then I debug the source code **H2SchemaMetaDataLoader.java** at line 112, just like below
   
   ![image](https://user-images.githubusercontent.com/21291945/220283685-7cf668b3-8025-4fea-b0e6-28cab4f9bec6.png)
   
   ## Reason analyze (If you can)
   I have used the original datasource (not shardingDatasource) to init my tables in H2, and then **H2SchemaMetaDataLoader** will load the meta data from the datasource.
   
   From the screenshot,we can find that the **dataTypeMap** does not contains the dataType `'4'`, because the **dataTypeMap** is the TYPE_NAME to DATA_TYPE mappings, just like below
   ![image](https://user-images.githubusercontent.com/21291945/220288213-a4abb342-711c-4cd3-84b4-e094b015de55.png)
   
   ## Solution
   In my option, if we can directly use the value of dataType, and not get from **dataTypeMap** ?
   
   
   


-- 
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] XinShepherd commented on issue #24276: When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException

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

   > > From the screenshot,we can find that the **dataTypeMap** does not contains the dataType `'4'`, because the **dataTypeMap** is the TYPE_NAME to DATA_TYPE mappings, just like below
   > 
   > * An extra topic is that in the previous H2DataBase mail list, this was pointed out as an error design of H2DataBase V1. Refer to [Update H2DataBase to 2.x and drop support for H2Database 1.x #19964](https://github.com/apache/shardingsphere/pull/19964) . Because there is no way to test H2Database V1 in the unit test, I am not sure that similar operations are helpful for H2DataBase V1.
   
   Thanks. So do you mean that I need to upgrade my H2 version from V1 to V2 ? Now shardingsphere-jdbc can work with this error, but I don't know if it will cause other errors.


-- 
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 #24276: When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException

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

   Hi @XinShepherd, thank you for your feedback. Can you try to fix this bug?


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


Re: [I] When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException [shardingsphere]

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

   - I'm just updating the current issue to avoid future misunderstandings. `org.apache.shardingsphere.infra.metadata.database.schema.loader.dialect.H2SchemaMetaDataLoader` has been refactored into `org.apache.shardingsphere.infra.database.h2.metadata.data.loader.H2MetaDataLoader`. There is still no related PR, and there is almost no way to test H2database V1 Server through H2database V2 Client.


-- 
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 #24276: When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException

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

   @linghengqian Thank you very much for your sharing, which means that the H2 2.x version has corrected the design errors in 1.x, and ShardingSphere currently supports it according to 2.x.


-- 
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] XinShepherd commented on issue #24276: When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException

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

   > * From a maintainability point of view, I feel that a downstream project should not stay at H2Database V1, because according to discussions on the H2Database maillist, V1 will not continue to release new versions.
   > * You can still make a PR, because I don't know why this method is designed like this in the first place.
   Thanks a lot @linghengqian . I upgrade my H2 version now and it works. And also, I will make a PR in the future if necessary. 
   


-- 
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] linghengqian commented on issue #24276: When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException

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

   @XinShepherd 
   
   - From a maintainability point of view, I feel that a downstream project should not stay at H2Database V1, because according to discussions on the H2Database maillist, V1 will not continue to release new versions.  
   
   - You can still make a PR, because I don't know why this method is designed like this in the first place.


-- 
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] linghengqian commented on issue #24276: When H2SchemaMetaDataLoader load column meta data, it will cause NullPointerException

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

   > From the screenshot,we can find that the **dataTypeMap** does not contains the dataType `'4'`, because the **dataTypeMap** is the TYPE_NAME to DATA_TYPE mappings, just like below
   
   - An extra topic is that in the previous H2DataBase mail list, this was pointed out as an error design of H2DataBase V1. Refer to https://github.com/apache/shardingsphere/pull/19964 . Because there is no way to test H2Database V1 in the unit test, I am not sure that similar operations are helpful for H2DataBase V1.
   


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