Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShardingSphere-JDBC got NullPointerException error with postgresql 14 version #33347

Open
carlors opened this issue Oct 22, 2024 · 0 comments
Open

Comments

@carlors
Copy link

carlors commented Oct 22, 2024

Bug Report

Which version of ShardingSphere did you use?

5.1.2

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

Execute select statement and return query result successfully when I query the sharding tables.

Actual behavior

The ShardingSphere-JDBC return an error:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.lang.NullPointerException
The error occurred while handling results
SQL: select id, uid, status,ctime from table_name WHERE uid =? order by ctime desc;
Cause: java.lang.NullPointerException
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:97)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439)
at com.sun.proxy.$Proxy356.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
at com.sun.proxy.$Proxy406.selectByExample(Unknown Source)

Reason analyze (If you can)

The ShardingSphere-JDBC can not get shard table's meta information for aws aurora postgresql 14.11 version when the db user is not same with the table owner.Since everything works well with postgresql 12.8 before I upgrade the db to postgresql 14.11 version.

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

1.Create one aws aurora postgresql cluster which engine version is 14.11,and create two database db1 and db2;
2.Create a table both in db1 and db2, change the table owner to user2;
alter table owner to user2;
3.Set ShardingSphere-JDBC db user as user1

dataSources:
  ds_0:
    url: jdbc:postgresql://xxx.cluster-ckcvjkzxh8bd.ap-northeast-1.rds.amazonaws.com:5432/db1?prepareThreshold=0
    username: user1
    password: user1password
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1
  ds_1:
    url: jdbc:postgresql://xxx.cluster-ckcvjkzxh8bd.ap-northeast-1.rds.amazonaws.com:5432/db2?prepareThreshold=0
    username: user1
    password: user1password
    connectionTimeoutMilliseconds: 30000
    idleTimeoutMilliseconds: 60000
    maxLifetimeMilliseconds: 1800000
    maxPoolSize: 50
    minPoolSize: 1

4.Config table shard rule the same as offcial example and start the application and execute the query.

Example codes for reproduce this issue (such as a github link).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants