You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "DengQin (via GitHub)" <gi...@apache.org> on 2024/10/21 13:12:07 UTC
[I] Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
DengQin opened a new issue, #33339:
URL: https://github.com/apache/shardingsphere/issues/33339
## Question
.278277293+08:00
### Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object
2024-10-21T18:52:20.278289903+08:00
; uncategorized SQLException; SQL state [HY000]; error code [30000]; Unknown exception: Cannot invoke method hashCode() on null object; nested exception is java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object
2024-10-21T18:52:20.278305818+08:00
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89) ~[spring-jdbc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
2024-10-21T18:52:20.278318225+08:00
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
2024-10-21T18:52:20.278330711+08:00
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-5.2.6.RELEASE.jar:5.2.6.RELEASE]
2024-10-21T18:52:20.278339694+08:00
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88) ~[mybatis-spring-2.0.5.jar:2.0.5]
2024-10-21T18:52:20.278352522+08:00
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440) ~[mybatis-spring-2.0.5.jar:2.0.5]
2024-10-21T18:52:20.278360916+08:00
at com.sun.proxy.$Proxy141.selectList(Unknown Source) ~[?:?]
2024-10-21T18:52:20.278372966+08:00
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223) ~[mybatis-spring-2.0.5.jar:2.0.5]
--
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
Re: [I] Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2426818877
<img width="1740" alt="image" src="https://github.com/user-attachments/assets/1ff6cb32-c3ec-4d77-9001-d022d4e8ad54">
Concurrent modification problems with simultaneous access by multiple threads may occur
--
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] Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2426696449
It seems that there is a conflict with other sharding algorithms in the concurrency situation
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2428780130
> * This change was originally introduced by the SPI I designed, but it did not break existing unit tests. Can you open a PR with the new unit tests? Or provide a git repository with the unit tests? There has been a lack of attention paid to the handling of groovyshell class instances.
> * By the way, the reason I introduced changes in this algorithm class is to get rid of groovy in the master branch of shardingsphere. It is not reasonable to use a specific SPI implementation class in `#init()`. Potential implementations of Python, JavaScript, Ruby, and WASM Row Value Expressions may still be put into this Java class. However, the relevant proposal was initially blocked by an issue on the GraalVM CE side. With the decoupling of GraalVM Truffle from the GraalVM SDK, I can re-examine the design of the relevant SPI.
InlineExpressionParser obtains the singleton object through SPI, but the inlineExpression field property is shared and is not thread-safe. For example:
Step 1: A normal query, InlineExpressionParserFactory. NewInstance (algorithmExpression) performed, .evaluateClosure().rehydrate(new Expando(), null, null); Not yet executed.
Step 2: another request perform a InlineExpressionParserFactory. NewInstance (algorithmExpression), the first step will lead to the request in the value of the change.
Step 3: An exception caused by multi-threaded modifications will appear
<img width="1567" alt="image" src="https://github.com/user-attachments/assets/8c85f139-c298-47c6-9814-a53b7e194e68">
--
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] Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2428661258
<img width="857" alt="image" src="https://github.com/user-attachments/assets/2f9c7721-a2be-42d9-8ec9-6ed428e6839c">
<img width="1433" alt="image" src="https://github.com/user-attachments/assets/828fd06c-a94b-414b-ac55-97460b10b9af">
This is my temporary solution, rewriting the InlineShardingAlgorithm via SPI
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2428784903
Loading InlineExpressionParser through SPI is reasonable, but the properties in the parser must be thread-safe
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2428797971
It is easy to occur when the number of requests is large and the number of sharding rules is large. If there is only one sharding strategy, it will not occur
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2428924304
- It sounds like it's really just a matter of using the volatile keyword for specific variables? The associated variable should not be read very often?
- I still haven't had time to verify it. Are you going to submit a PR with unit tests?
--
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] Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2426647651
config:
# 分片配置
- !SHARDING
tables:
t_benefit_distribute_record:
actualDataNodes: ds-marketing.t_benefit_distribute_record_$->{0..15}
tableStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: t_benefit_distribute_record_inline
t_benefit_distribute_record_inline:
type: INLINE
props:
algorithm-expression: t_benefit_distribute_record_$->{user_id % 16}
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2458921521
I was unable to successfully reproduce this in the master branch. Consider providing your unit tests.
--
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] Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "DengQin (via GitHub)" <gi...@apache.org>.
DengQin commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2426692143
sharding config:
rules:
# 单表
- !SINGLE
tables:
- ds-marketing.*
defaultDataSource: ds-marketing
# 分片配置
- !SHARDING
tables:
t_benefit_distribute_record:
actualDataNodes: ds-marketing.t_benefit_distribute_record_$->{0..15}
tableStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: t_benefit_distribute_record_inline
# databaseStrategy:
# hint:
# shardingAlgorithmName: database_inline
t_activity_submit_record:
actualDataNodes: ds-marketing.t_activity_submit_record_$->{0..3}
tableStrategy:
standard:
shardingColumn: user_info
shardingAlgorithmName: t_activity_submit_record_inline
# databaseStrategy:
# hint:
# shardingAlgorithmName: database_inline
t_activity_stock:
actualDataNodes: ds-marketing.t_activity_stock_$->{0..7}
tableStrategy:
standard:
shardingColumn: activity_id
shardingAlgorithmName: t_activity_stock_inline
# databaseStrategy:
# hint:
# shardingAlgorithmName: database_inline
t_activity_user_times:
actualDataNodes: ds-marketing.t_activity_user_times_$->{0..7}
tableStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: t_activity_user_times_inline
# databaseStrategy:
# hint:
# shardingAlgorithmName: database_inline
t_raffle_winner_sub_log:
actualDataNodes: ds-marketing.t_raffle_winner_sub_log_$->{0..19}
tableStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: t_raffle_winner_sub_log_inline
# databaseStrategy:
# hint:
# shardingAlgorithmName: database_inline
t_user_business_event:
actualDataNodes: ds-marketing.t_user_business_event_$->{0..15}
tableStrategy:
standard:
shardingColumn: business_id
shardingAlgorithmName: t_user_business_event_inline
# databaseStrategy:
# hint:
# shardingAlgorithmName: database_inline
defaultDatabaseStrategy:
hint:
shardingAlgorithmName: database_algorithm_inline
shardingAlgorithms:
database_inline:
type: HINT_INLINE
props:
algorithm-expression: ds-marketing
database_algorithm_inline:
type: CLASS_BASED
props:
strategy: HINT
algorithmClassName: comXXXX
t_benefit_distribute_record_inline:
type: INLINE
props:
algorithm-expression: t_benefit_distribute_record_$->{user_id % 16}
t_activity_submit_record_inline:
type: INLINE
props:
algorithm-expression: t_activity_submit_record_$->{Math.abs(user_info.hashCode()) % 4}
t_activity_stock_inline:
type: INLINE
props:
algorithm-expression: t_activity_stock_$->{activity_id % 8}
t_activity_user_times_inline:
type: INLINE
props:
algorithm-expression: t_activity_user_times_$->{user_id % 8}
t_raffle_winner_sub_log_inline:
type: INLINE
props:
algorithm-expression: t_raffle_winner_sub_log_$->{user_id % 20}
t_user_business_event_inline:
type: INLINE
props:
algorithm-expression: t_user_business_event_$->{Math.abs(business_id.hashCode()) % 16}
props:
sql-show: true
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #33339: ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object
URL: https://github.com/apache/shardingsphere/issues/33339
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2474676413
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
--
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] ”InlineShardingAlgorithm“ It's not thread-safe, Occasionally the following errors occur: Cause: java.sql.SQLException: Unknown exception: Cannot invoke method hashCode() on null object [shardingsphere]
Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #33339:
URL: https://github.com/apache/shardingsphere/issues/33339#issuecomment-2428747985
- This change was originally introduced by the SPI I designed, but it did not break existing unit tests. Can you open a PR with the new unit tests? Or provide a git repository with the unit tests? There has been a lack of attention paid to the handling of groovyshell class instances.
- By the way, the reason I introduced changes in this algorithm class is to get rid of groovy in the master branch of shardingsphere. It is not reasonable to use a specific SPI implementation class in `#init()`. Potential implementations of Python, JavaScript, Ruby, and WASM Row Value Expressions may still be put into this Java class. However, the relevant proposal was initially blocked by an issue on the GraalVM CE side. With the decoupling of GraalVM Truffle from the GraalVM SDK, I can re-examine the design of the relevant SPI.
--
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