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

请问如何控制事物手动回滚? #34

Closed
persistGithub opened this issue Jan 9, 2018 · 10 comments
Closed

请问如何控制事物手动回滚? #34

persistGithub opened this issue Jan 9, 2018 · 10 comments

Comments

@persistGithub
Copy link

类似于 Spring的 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 因为不一定是异常才需要回滚,我没有在文档上看到手动回滚的东西 谢谢

@persistGithub
Copy link
Author

我现在有一个业务,需要在新建用户后进行其它的用户相关信息的保存,是两个不同的业务实体和spring boot
服务 ,后面的用户信息关联了保存的用户ID,使用的是JPA, 我看到tx的日志是在commit,但是会一直insert user
最后报错,,

@persistGithub
Copy link
Author

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction

@persistGithub
Copy link
Author

lcn transaction over, res -> groupId:jOlZWY7E and state is rollback

@xlorne
Copy link
Contributor

xlorne commented Jan 9, 2018

是不是出现了两个模块操作同一行数据的情况了?

@xlorne
Copy link
Contributor

xlorne commented Jan 9, 2018

LCNTransactionAspectSupport. currentTransactionStatus(). setRollbackOnly();

@xlorne
Copy link
Contributor

xlorne commented Jan 9, 2018

事务手动回滚

@persistGithub
Copy link
Author

C是一个公共服务,A服务和B服务都引用了他 A服务新建一条数据,B服务中将这个条数据的ID设置为关联关系,在C服务中保存 就不行 会保存 而且是多次循环插入

@persistGithub
Copy link
Author

C服务不是web服务.没有配置数据源

@xlorne
Copy link
Contributor

xlorne commented Jan 9, 2018

C 是操作数据源的服务?

@xlorne xlorne closed this as completed Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants