txlcn-demo icon indicating copy to clipboard operation
txlcn-demo copied to clipboard

在参与方 的事物中如果有delete语句 回滚失败

Open 312527814 opened this issue 4 years ago • 4 comments

@Override
@TxcTransaction(propagation = DTXPropagation.SUPPORTS)
@Transactional
public String rpc(String value) {

    Demo demo = new Demo();
    demo.setId(127l);
    demo.setDemoField(value);
   
    demoMapper.update(demo);

    demoMapper.deleteByKId(129l);
   return “ok”;

}

312527814 avatar Jul 20 '21 18:07 312527814

这是啥意思?

At 2021-07-21 02:32:39, "312527814" @.***> wrote:

@Override

@TxcTransaction(propagation = DTXPropagation.SUPPORTS)

@Transactional

public String rpc(String value) {

Demo demo = new Demo();

demo.setId(127l);

demo.setDemoField(value);



demoMapper.update(demo);



demoMapper.deleteByKId(129l);

return “ok”;

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

luoyonghui55 avatar Jul 28 '21 16:07 luoyonghui55

事物发起方(A) ,参与方(D)
如果D的事物中有删除数据的语句,在A 的事物中调用D接口,返回之后A中出现了异常,此时回滚,D中的事物回滚会失败。

` /* 事物A */ @Override @TxcTransaction(propagation = DTXPropagation.SUPPORTS) @Transactional public String rpc(String value) {

 // 调用事物D
    String dResp = dDemoClient.rpc(value);
    // 手动异常, 回滚
    int i = 1 / 0;
    return dResp +" > " + "ok-client";

}`

/* 事物D */ @Override @TxcTransaction(propagation = DTXPropagation.SUPPORTS) @Transactional public String rpc(String value) {

Demo demo = new Demo();
demo.setId(127l);
demo.setDemoField(value);

demoMapper.update(demo);

demoMapper.deleteByKId(129l);

return “ok”; }`

312527814 avatar Aug 02 '21 12:08 312527814

那遇到这种情况,咋弄?

在 2021-08-02 20:10:59,"312527814" @.***> 写道:

事物发起方(A) ,参与方(D) 如果D的事物中有删除数据的语句,在A 的事物中调用D接口,返回之后A中出现了异常,此时回滚,D中的事物回滚会失败。

/* 事物A / @Override @LcnTransaction(propagation= DTXPropagation.REQUIRED) @Transactional public String execute(String value) { / 事物B */ // ServiceD String dResp = dDemoClient.rpc(value); // 手动异常,DTX B回滚 int i = 1 / 0; return dResp + " > " + eResp + " > " + "ok-client"; }

` /* 事物D */ @override @TxcTransaction(propagation = DTXPropagation.SUPPORTS) @transactional public String rpc(String value) {

Demo demo = new Demo();

demo.setId(127l);

demo.setDemoField(value);

demoMapper.update(demo);

demoMapper.deleteByKId(129l);

return “ok”; }`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

luoyonghui55 avatar Aug 06 '21 12:08 luoyonghui55

那遇到这种情况,咋弄? 在 2021-08-02 20:10:59,"312527814" @.**> 写道: 事物发起方(A) ,参与方(D) 如果D的事物中有删除数据的语句,在A 的事物中调用D接口,返回之后A中出现了异常,此时回滚,D中的事物回滚会失败。 / 事物A / @override @LcnTransaction(propagation= DTXPropagation.REQUIRED) @transactional public String execute(String value) { / 事物B */ // ServiceD String dResp = dDemoClient.rpc(value); // 手动异常,DTX B回滚 int i = 1 / 0; return dResp + " > " + eResp + " > " + "ok-client"; } /* 事物D */ @override @TxcTransaction(propagation = DTXPropagation.SUPPORTS) @transactional public String rpc(String value) { Demo demo = new Demo(); demo.setId(127l); demo.setDemoField(value); demoMapper.update(demo); **demoMapper.deleteByKId(129l);** return “ok”; } — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

不知道啊 这不是问来了么 哈哈。。

感觉还是老老实实的 用Seata吧 。

312527814 avatar Aug 09 '21 05:08 312527814