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

An null exception occurred when integrating seata #24735

Closed
ulwx opened this issue Mar 22, 2023 · 3 comments · Fixed by #30146
Closed

An null exception occurred when integrating seata #24735

ulwx opened this issue Mar 22, 2023 · 3 comments · Fixed by #30146
Assignees

Comments

@ulwx
Copy link

ulwx commented Mar 22, 2023

@Transactional(propagation = Propagation.REQUIRED)
 @GlobalTransactional
 public void updateUseAkDs() {
     TransactionTypeHolder.set(TransactionType.BASE);
     addressDao.updateMdForMaster2(1, "123");
     try {
         addressDao.updateMdForMaster1(2, "abc");
     } catch (Exception ex) {
         LOGGER.debug(ex + "");
     }

 }


An error is reported when integrating seata. When we use sharding-jdbc with seata, a null exception will be reported! The above is my code.

@TeslaCN
Copy link
Member

TeslaCN commented Mar 23, 2023

Hi @ulwx
Please provide more information about your question.

@ulwx
Copy link
Author

ulwx commented Mar 24, 2023

@transactional(propagation = Propagation.REQUIRED)
@GlobalTransactional
public void updateUseAkDs() {
TransactionTypeHolder.set(TransactionType.BASE);
addressDao.updateMdForMaster2(1, "123");
try {
addressDao.updateMdForMaster1(2, "abc");
} catch (Exception ex) {
LOGGER.debug(ex + "");
}

}

@GlobalTransactional is an annotation from seata, indicating that this is a global transaction. When TransactionTypeHolder. set (TransactionType. BASE) is used in a method(using the @ GlobalTransactional annotation), an error will be reported. The reason is that sharding-jdbc determines in the code that if it is in a global transaction, SeataATShardingSphereTransactionManager#begin() is not executed, finally, in the code ”SeataTransactionHolder. get(). commit()” in the SeataATShardingSphereTransactionManager#commit() method, SeataTransactionHolder. get()=null, resulting in a null exception!

@github-actions github-actions bot added the stale label Jul 12, 2023
@linghengqian
Copy link
Member

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