dtm-labs / dtm

A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.
http://d.dtm.pub
BSD 3-Clause "New" or "Revised" License
10.18k stars 979 forks source link

Saga模式下,分支事务超时问题 #519

Open 1528992118 opened 3 months ago

1528992118 commented 3 months ago

我使用的Dtm Server版本为1.18.0,下面是我注册的本次saga事务信息:

{
    "steps": [{
        "action": "http://localhost:9002/ccfmonitor/internal/v1/saga/test/action",
        "compensate": "http://localhost:9002/ccfmonitor/internal/v1/saga/test/compensate"
    }, {
        "action": "http://localhost:9002/ccfmonitor/internal/v1/saga/test2/action",
        "compensate": "http://localhost:9002/ccfmonitor/internal/v1/saga/test2/compensate"
    }],
    "payloads": ["{\"name\":\"dtm\"}", "{\"name\":\"dtm\"}"],
    "customData": "{\"concurrent\":true,\"orders\":{\"0\":[1]}}",
    "waitResult": false,
    "timeoutToFail": 30,
    "retryInterval": 60,
    "passthroughHeaders": [],
    "branchHeaders": {},
    "gid": "ef6cb7d2-f4e1-4905-ba26-b8c700de0427",
    "transType": "saga",
    "subType": "saga"
}

在使用过程中,主要想看下分支事务在模拟耗时情况下,DTM的处理机制,当我在ccfmonitor/internal/v1/saga/test2/action具体代码中模拟了线程睡眠10秒后,我发现Dtm Server会判定本次action接口有问题,并一直触发重试机制。这里我有个疑问,我不是将全局的超时时间设置为了30秒,为什么Dtm Server还会一直触发重试?

image

yedf2 commented 2 months ago

接口调用超时是比较短的,不是通过timeoutToFail设置的。接口调用一般不会超过3秒的。一个接口调用超过3秒了,通常意味着设计有问题。