apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.35k stars 8.79k forks source link

Global rollback fails when an exception is thrown manually #1171

Closed lw5946 closed 5 years ago

lw5946 commented 5 years ago

Ⅰ. Issue Description

Ⅱ. Describe what happened

I use the code in the seata-sample(springboot-dubbo-seata) example

//打开注释测试事务发生异常后,全局回滚功能
if (true) {
    throw new RuntimeException("测试抛异常后,分布式事务回滚!");
}

However, no global rollback occurred. And no other exceptions were thrown during operation.

Ⅲ. Describe what you expected to happen

Ⅳ. How to reproduce it (as minimally and precisely as possible)

  1. xxx
  2. xxx
  3. xxx

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

fescar-robot commented 5 years ago

Hi @lw5946, we detect non-English characters in the issue. This comment is an auto translation from @fescar-robot to help other users to understand this issue. We encourage you to describe your issue in English which is more friendly to other users.

Global rollback fails when an exception is thrown manually

Ⅰ. Issue Description

Ⅱ. Describe what happened

I use the code in the seata-sample(springboot-dubbo-seata) example

/ / Open the comment test transaction after the exception, the global rollback function
if (true) {
Throw new RuntimeException("After testing throwing an exception, distributed transaction rollback!");
}

However, no global rollback occurred. And no other exceptions were thrown during operation.

Ⅲ. Describe what you expected to happen

Ⅳ. How to reproduce it (as minimally and precisely as possible)

  1. xxx
  2. xxx
  3. xxx

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

romeoblog commented 5 years ago

@lw5946 Your application may not be registered with the Seata DataSource Proxy. Check if the program has configured the following information:

@Primary
@Bean("dataSource")
public DataSourceProxy dataSource(DruidDataSource druidDataSource) {
     return new DataSourceProxy(druidDataSource);
}
lw5946 commented 5 years ago

In the official springboot-dubbo-seata example, account, order and storage all have registered with the Seata Data Source Proxy. The access interface is the business module, which does not register with the Seata Data Source Proxy, but the module does not operate the database.

lw5946 commented 5 years ago

This issue has been solved in the latest version, so close this issue