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

the return value of "org.apache.shardingsphere.transaction.base.seata.at.SeataTransactionHolder.get()" is null #29681

Closed
Python-IBM opened this issue Jan 9, 2024 · 4 comments · Fixed by #30146 or #30304

Comments

@Python-IBM
Copy link

Python-IBM commented Jan 9, 2024

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

5.4.0

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

ShardingSphere-JDBC

Expected behavior

Can perform transaction rollback normally.

Actual behavior

Transaction rollback encountered an exception.

Reason analyze (If you can)

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

  1. sharding rule configuration
    image

  2. exception log
    org.springframework.jdbc.UncategorizedSQLException:
    Error updating database. Cause: java.sql.SQLException: Unknown exception: Cannot invoke "io.seata.tm.api.GlobalTransaction.rollback()" because the return value of "org.apache.shardingsphere.transaction.base.seata.at.SeataTransactionHolder.get()" is null
    The error may exist in file [E:\SpringProject\demo-dubbo\samples-account\target\classes\mapper\TAccountMapper.xml]
    The error may involve defaultParameterMap
    The error occurred while setting parameters
    QL: update t_account set amount = amount-5.0 where user_id = ?
    Cause: java.sql.SQLException: Unknown exception: Cannot invoke "io.seata.tm.api.GlobalTransaction.rollback()" because the return value of "org.apache.shardingsphere.transaction.base.seata.at.SeataTransactionHolder.get()" is null
    ; uncategorized SQLException; SQL state [HY000]; error code [30000]; Unknown exception: Cannot invoke "io.seata.tm.api.GlobalTransaction.rollback()" because the return value of "org.apache.shardingsphere.transaction.base.seata.at.SeataTransactionHolder.get()" is null
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:93) ~[mybatis-spring-3.0.3.jar:3.0.3]
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439) ~[mybatis-spring-3.0.3.jar:3.0.3]
    at jdk.proxy2/jdk.proxy2.$Proxy98.update(Unknown Source) ~[na:na]
    at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:288) ~[mybatis-spring-3.0.3.jar:3.0.3]
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:67) ~[mybatis-3.5.14.jar:3.5.14]
    at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:141) ~[mybatis-3.5.14.jar:3.5.14]
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) ~[mybatis-3.5.14.jar:3.5.14]
    at jdk.proxy2/jdk.proxy2.$Proxy99.decreaseAccount(Unknown Source) ~[na:na]
    at com.demo.account.service.impl.TAccountServiceImpl.decreaseAccount(TAccountServiceImpl.java:36) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:352) ~[spring-aop-6.1.2.jar:6.1.2]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:713) ~[spring-aop-6.1.2.jar:6.1.2]
    at com.demo.account.service.impl.TAccountServiceImpl$$SpringCGLIB$$0.decreaseAccount() ~[classes/:na]
    at com.demo.service.account.ITAccountServiceDubboWrap1.invokeMethod(ITAccountServiceDubboWrap1.java) ~[classes/:na]
    at org.apache.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:89) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:100) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.config.invoker.DelegateProviderMetaDataInvoker.invoke(DelegateProviderMetaDataInvoker.java:55) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:56) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.ClassLoaderCallbackFilter.invoke(ClassLoaderCallbackFilter.java:38) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at com.alibaba.dubbo.rpc.Invoker$CompatibleInvoker.invoke(Invoker.java:77) ~[dubbo-3.2.10.jar:3.2.10]
    at io.seata.integration.dubbo.alibaba.AlibabaDubboTransactionPropagationFilter.invoke(AlibabaDubboTransactionPropagationFilter.java:45) ~[seata-all-2.0.0.jar:2.0.0]
    at com.alibaba.dubbo.rpc.Filter.invoke(Filter.java:34) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:80) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:45) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.seata.SeataTransactionPropagationProviderFilter.invoke(SeataTransactionPropagationProviderFilter.java:66) ~[dubbo-filter-seata-1.0.2.jar:1.0.2]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:108) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:54) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.AccessLogFilter.invoke(AccessLogFilter.java:120) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.metrics.observation.ObservationReceiverFilter.invoke(ObservationReceiverFilter.java:57) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:222) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:54) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:41) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.metrics.filter.MetricsFilter.invoke(MetricsFilter.java:86) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.metrics.filter.MetricsProviderFilter.invoke(MetricsProviderFilter.java:37) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.ProfilerServerFilter.invoke(ProfilerServerFilter.java:66) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:145) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CopyOfFilterChainNode.invoke(FilterChainBuilder.java:349) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder$CallbackRegistrationInvoker.invoke(FilterChainBuilder.java:197) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:167) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:110) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:205) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52) ~[dubbo-3.2.10.jar:3.2.10]
    at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:64) ~[dubbo-3.2.10.jar:3.2.10]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
    at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:39) ~[dubbo-3.2.10.jar:3.2.10]
    at java.base/java.lang.Thread.run(Thread.java:842) ~[na:na]
    Caused by: java.sql.SQLException: Unknown exception: Cannot invoke "io.seata.tm.api.GlobalTransaction.rollback()" because the return value of "org.apache.shardingsphere.transaction.base.seata.at.SeataTransactionHolder.get()" is null
    at org.apache.shardingsphere.infra.util.exception.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:62) ~[shardingsphere-infra-util-5.4.0.jar:5.4.0]
    at org.apache.shardingsphere.dialect.SQLExceptionTransformEngine.toSQLException(SQLExceptionTransformEngine.java:62) ~[shardingsphere-dialect-exception-core-5.4.0.jar:5.4.0]
    at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:416) ~[shardingsphere-jdbc-core-5.4.0.jar:5.4.0]
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) ~[HikariCP-5.0.1.jar:na]
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) ~[HikariCP-5.0.1.jar:na]
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:48) ~[mybatis-3.5.14.jar:3.5.14]
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:75) ~[mybatis-3.5.14.jar:3.5.14]
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.14.jar:3.5.14]
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.14.jar:3.5.14]
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.14.jar:3.5.14]
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) ~[mybatis-3.5.14.jar:3.5.14]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425) ~[mybatis-spring-3.0.3.jar:3.0.3]
    ... 62 common frames omitted
    Caused by: java.lang.NullPointerException: Cannot invoke "io.seata.tm.api.GlobalTransaction.rollback()" because the return value of "org.apache.shardingsphere.transaction.base.seata.at.SeataTransactionHolder.get()" is null
    at org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager.rollback(SeataATShardingSphereTransactionManager.java:132) ~[shardingsphere-transaction-base-seata-at-5.4.0.jar:5.4.0]
    at org.apache.shardingsphere.transaction.ConnectionTransaction.rollback(ConnectionTransaction.java:125) ~[shardingsphere-transaction-core-5.4.0.jar:5.4.0]
    at org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager.rollback(DriverDatabaseConnectionManager.java:172) ~[shardingsphere-jdbc-core-5.4.0.jar:5.4.0]
    at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.rollback(ShardingSphereConnection.java:199) ~[shardingsphere-jdbc-core-5.4.0.jar:5.4.0]
    at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeWithImplicitCommitTransaction(ShardingSpherePreparedStatement.java:446) ~[shardingsphere-jdbc-core-5.4.0.jar:5.4.0]
    at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:411) ~[shardingsphere-jdbc-core-5.4.0.jar:5.4.0]
    ... 75 common frames omitted

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

image

Copy link

github-actions bot commented Feb 8, 2024

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

@github-actions github-actions bot added the stale label Feb 8, 2024
@linghengqian
Copy link
Member

@linghengqian
Copy link
Member

  • This seems inconsistent with other issues. Please provide the full class name of @Transactional for testing, or provide a unit test through testcontainers-java.

@linghengqian
Copy link
Member

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