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

5.3.1 When integrating seata global transactions, if there are also global transactions on the periphery, the commit () method reports a null exception #24332

Closed
ulwx opened this issue Feb 24, 2023 · 1 comment · Fixed by #30146

Comments

@ulwx
Copy link

ulwx commented Feb 24, 2023

GlobalTransaction globalTransaction = GlobalTransactionContext.getCurrentOrCreate();
globalTransaction.begin(timeout * 1000);     
TransactionTypeHolder.set(TransactionType.BASE);
try{
    doInsert();
}finally {
    TransactionTypeHolder.clear();
}
globalTransaction.commit();

When the above code is running, doInsert() will throw a null exception, which is thrown by the commit() method in doInsert(). The reason is that when the shardingjdbc proxy commit() method is used, because the SeataATShardingSphereTransactionManager # begin() method has not been executed because of the existence of GlobalTransaction on the periphery, the TransactionTypeHolder # set() method has not been executed and is always empty, Thus, when the shardingjdbc agent commit() method is executed, the query is null through TransactionTypeHolder # get(), and a null pointer exception is reported!

@FlyingZC
Copy link
Member

Not support starting the SEATA AT transaction from the outside.ShardingSphere starts the SEATA AT transaction by itself.

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

Successfully merging a pull request may close this issue.

3 participants