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

Two datasources one datasources TX can not be roll-backed #2053

Closed
zhouxianrongtest opened this issue Mar 19, 2019 · 6 comments
Closed

Two datasources one datasources TX can not be roll-backed #2053

zhouxianrongtest opened this issue Mar 19, 2019 · 6 comments

Comments

@zhouxianrongtest
Copy link

zhouxianrongtest commented Mar 19, 2019

Bug Report:
1:there are two database A and B, A data sources declared @primary
2:Do a test on the DB A that insert multiple record to one table, the DB A transaction can be rock-backed when code throws Exception
3:Do a test on the DB B, but It can not be rock-backed, there have a few record be inserted to the table.
4: If move the @primary declare to the database B, the transaction can be rock-backed

Expect:
1:The test can be rock-backed successfully on the DB B.

sharding dependences:
<sharding.jdbc.core.version>1.5.4.1</sharding.jdbc.core.version>
<sharding.jdbc.transaction.storage.version>1.5.4.1</sharding.jdbc.transaction.storage.version>
<sharding.jdbc.config.spring.version>1.5.4.1</sharding.jdbc.config.spring.version>

Similar issure: #213

Debuged the sharding code found the cachedConnections is empty and then the setAutoCommit=true

Please give some help, tks

@zhouxianrongtest
Copy link
Author

AbstractConnectionAdapter.setAutoCommit()

@zhouxianrongtest
Copy link
Author

Use Spring-Boot to build the project.

@terrymanu
Copy link
Member

Hello, the version 1.5.4.1 is too old, please use 3.x.
By the way, we will do first release of 4.x soon.

@zhouxianrongtest
Copy link
Author

Now a little emergency, could you give some good solution?

@zhouxianrongtest
Copy link
Author

Bug Fixed:
Because used @primary so the DB A TransactionManager will be used always when insert to DB B, now we need assign the TransactionManager declear by manual.

for example:

@transactional(rollbackFor = Exception.class, value = "clusterDataSourceTransactionManager")
public void XX(xxObject param) throws Exception {

clusterDataSourceTransactionManager is the DB B TransactionManager declear, so the DB A need use masterDataSourceTransactionManager

@terrymanu
Copy link
Member

Out of service of this version, it is really too old.
The suggestion is upgrade to 3.x or 4.x version

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

No branches or pull requests

2 participants