shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

although atomikos rollback, but data still exist in database

Open EvanDylan opened this issue 7 years ago • 10 comments

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response more than 7 days and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

4.0.0-RC1

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-JDBC

Expected behavior

the use case as blow (ps : use atomikos)

@Transactional
    public void xaTransaction() {
        userMapper.insertUser(887, 20);
        throw new RuntimeException();
    }

the end line with throw RuntimeException, so the insert data user while be rollback

Actual behavior

although atomikos execute rollback, but data still exist in database;

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Example codes for reproduce this issue (such as a github link).

https://github.com/EvanDylan/sharding-samples.git

EvanDylan avatar Jun 04 '19 11:06 EvanDylan

hi, you have integrated XA transaction in a wrong way. please reference our example.

I have not seen @ShardingTransactionType or TransactionTypeHolder API in your example.

cherrylzhao avatar Jun 06 '19 02:06 cherrylzhao

In the version of 4.0.0-RC1 ,annotation of SharindTransationType is not available and the examples of integrated with spring namespace without TransantionTypeHolder too.

EvanDylan avatar Jun 06 '19 05:06 EvanDylan

You can running the demo directly and rollback log will be print by atomikos, i am not sure this issue cause by Sharding-JDBC

EvanDylan avatar Jun 06 '19 05:06 EvanDylan

this atomikos log is come for spring-boot jpa

cherrylzhao avatar Jun 06 '19 05:06 cherrylzhao

you have open boot autoconfiguration,boot have discovery atomikos jar, so it instance atomikos transaction manager directory, but this is not what sharding need.

cherrylzhao avatar Jun 06 '19 05:06 cherrylzhao

In the version of 4.0.0-RC1 ,annotation of SharindTransationType is not available and the examples of integrated with spring namespace without TransantionTypeHolder too.

you can mvn clean install from our https://github.com/OpenSharding/shardingsphere-spi-impl

cherrylzhao avatar Jun 06 '19 05:06 cherrylzhao

thanks a lot,I had big mistake,lol

EvanDylan avatar Jun 06 '19 05:06 EvanDylan

@cherrylzhao the example you has provided also use spring boot autoconfiguration too. So could you pelease update the example and fix the error.

EvanDylan avatar Jun 10 '19 06:06 EvanDylan

example is ok, we have provided sharding-transaction-spring-boot-starter to avoid it happen, or you can use @exculed annotation manually.

cherrylzhao avatar Jun 10 '19 06:06 cherrylzhao

got it, thanks again

EvanDylan avatar Jun 10 '19 08:06 EvanDylan