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

gorm gen关联操作导致的死锁问题 #7398

Open
alicksnake22 opened this issue Mar 23, 2025 · 7 comments
Open

gorm gen关联操作导致的死锁问题 #7398

alicksnake22 opened this issue Mar 23, 2025 · 7 comments
Assignees
Labels

Comments

@alicksnake22
Copy link

alicksnake22 commented Mar 23, 2025

Image

这是一个常规的更新admin的操作

先查询admin

然后修改他的头像,最后clear旧角色,append上新的角色

红框代码在绿框前面回导致事务等待死锁

红框代码放到绿框代码后面则不会

为什么会出现这种情况?两者不是使用同一个事务?

@alicksnake22 alicksnake22 added the type:question general questions label Mar 23, 2025
@github-actions github-actions bot added type:missing reproduction steps missing reproduction steps and removed type:question general questions labels Mar 23, 2025
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@alicksnake22
Copy link
Author

经过测试,假设在最后执行c.Tx.Rollback(),是无法回滚绿色框代码的,是否说明绿色代码已经不在c.Tx下了?

Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@alicksnake22
Copy link
Author

c.Tx已经是begin后的事务了

@alicksnake22
Copy link
Author

@jinzhu 谢谢抽空解答,关于gorm gen里面事务跳出的问题

Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

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

No branches or pull requests

2 participants