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

项目里的数据库事务对象共用问题 #41

Open
dustinzyn opened this issue Nov 2, 2022 · 4 comments
Open

项目里的数据库事务对象共用问题 #41

dustinzyn opened this issue Nov 2, 2022 · 4 comments

Comments

@dustinzyn
Copy link

Worker().Store().Set("freedom_local_transaction_db", t.db),把事务对象都用一个key:freedom_local_transaction_db 存的话,并发请求时,获取的都是同一个,难道不会有问题吗?还是我的理解有问题,可以解答一下吗

@8treenet
Copy link
Owner

8treenet commented Nov 2, 2022

不存在这样的问题。因为事务不支持并发。
可以单测下 直接什么都不用 就官方db试下并发事务

@dustinzyn
Copy link
Author

我疑惑的是,在不同的请求里,从内存里获取的是同一个begin开启的事务,不会互相commit影响吗

@8treenet
Copy link
Owner

8treenet commented Nov 3, 2022

互不影响。简单的来说 每个请求都是独立的controller,service,repo,factory。

@8treenet
Copy link
Owner

8treenet commented Nov 3, 2022

还有infra 和work

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