Skip to content

[issue][Compensable][timeout]global service set timeout,when all sub-services are complete and global service timeout, the result is unstable #24

@asiroliu

Description

@asiroliu

Describe The Bug

global service set timeout,when all sub-services are complete and global service timeout, the result is unstable

TXLE Version

./txle -v
txle version 9.9.9.9 d2249e2df2dff0eff68b7f4bea37ba4887d8e2ca

To Reproduce

Steps to reproduce the behavior:

  1. set global service timeout to 3 secs
    @SagaStart(category = "txle-springboot-global", timeout = 3)
    @GetMapping("/testGlobalTransactionGlobalTimeout_3/{userId}/{amount}/{merchantid}")
    public String testGlobalTransactionGlobalTimeout_3(@PathVariable int userId, @PathVariable double amount, @PathVariable int merchantid) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        System.err.println("[" + sdf.format(new Date()) + "] Executing method '" + this.getClass() + ".testGlobalTransactionGlobalTimeout_3'. \t\tParameters[userId = " + userId + ", amount = " + amount + ", merchantid = " + merchantid + "]");

        try {
            // 1.扣款
            restTemplate.postForObject(userServiceUrl + "/deductMoneyFromUser/{userId}/{balance}", null, String.class, userId, amount);


            // 2.汇款
            restTemplate.postForObject(merchantServiceUrl + "/payMoneyToMerchant/{merchantid}/{balance}", null, String.class, merchantid, amount);

            try {
                Thread.sleep(6000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            return TxleConstants.OK;
        } catch (Exception e) {
            throw e;
        }
    }
  1. send http request trigger the global service

Expected Result

the global service should be successful, and not roll back the data

Real Result

the global service response is failed(500 Internal Server Error), and roll back the data

Logs

serviceName creationTime type
sample-txle-springboot-user 2020/4/7 06:32:04 TxStartedEvent
sample-txle-springboot-user 2020/4/7 06:32:04 TxEndedEvent
sample-txle-springboot-merchant 2020/4/7 06:32:04 TxStartedEvent
sample-txle-springboot-merchant 2020/4/7 06:32:04 TxEndedEvent
sample-txle-springboot-global 2020/4/7 06:32:09 TxAbortedEvent
sample-txle-springboot-user 2020/4/7 06:32:09 TxCompensatedEvent
sample-txle-springboot-merchant 2020/4/7 06:32:09 TxCompensatedEvent
sample-txle-springboot-global 2020/4/7 06:32:10 SagaEndedEvent

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions