Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store.mode=db 事务结束后globalsession的状态未正确修改为commited #5045

Closed
1 task
gaozx95 opened this issue Nov 2, 2022 · 6 comments · Fixed by #5050, #5145 or #5464
Closed
1 task

store.mode=db 事务结束后globalsession的状态未正确修改为commited #5045

gaozx95 opened this issue Nov 2, 2022 · 6 comments · Fixed by #5050, #5145 or #5464
Assignees
Labels
task: help-wanted Extra attention is needed

Comments

@gaozx95
Copy link

gaozx95 commented Nov 2, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

Ⅱ. Describe what happened

saga模式下
store.mode = db 事务结束后globalsession的状态未正确修改为commited,依然还是begin,导致global表中状态为1,等待1800s后会对事务进行回滚;
SessionHelper中endCommitted的中的

    public static void endCommitted(GlobalSession globalSession, boolean retryGlobal) throws TransactionException {
        if (retryGlobal || !DELAY_HANDLE_SESSION) {
            long beginTime = System.currentTimeMillis();
            boolean retryBranch = globalSession.getStatus() == GlobalStatus.CommitRetrying;
            globalSession.changeGlobalStatus(GlobalStatus.Committed);
            globalSession.end();
            if (!DELAY_HANDLE_SESSION) {
                MetricsPublisher.postSessionDoneEvent(globalSession, false, false);
            }
            MetricsPublisher.postSessionDoneEvent(globalSession, IdConstants.STATUS_VALUE_AFTER_COMMITTED_KEY, true,
                beginTime, retryBranch);
        } else {
            MetricsPublisher.postSessionDoneEvent(globalSession, false, false);
        }
    }

store.mode = db 时DELAY_HANDLE_SESSION为true,进不了分支,导致不能changeGlobalStatus为Committed

Ⅲ. Describe what you expected to happen

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

把DELAY_HANDLE_SESSION的取反去掉

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

  • JDK version :
  • Seata version:
  • OS :
  • Others:
@funky-eyes
Copy link
Contributor

这是特意做的延迟删除,在非at模式下会set一个内存的status让committed打点成功,saga这块漏掉了,你可以提个pr来修复这个问题吗?
image

@funky-eyes funky-eyes added the task: help-wanted Extra attention is needed label Nov 2, 2022
@wingchi-leung
Copy link
Contributor

我看了一下,是在SagaCore的doGlobalCommit方法中也添加这个判断嘛? 我可以试试吗?

@funky-eyes
Copy link
Contributor

funky-eyes commented Nov 3, 2022

我看了一下,是在SagaCore的doGlobalCommit方法中也添加这个判断嘛? 我可以试试吗?


if(!retring){
globalsession.setStatus(Committed)
}
放到
if(success && globalSession.getBranchsessions().isempty){

}
里面是不是就通用了?

@tuwenlin
Copy link
Contributor

tuwenlin commented Nov 4, 2022

image
这里已经把状态改成了Committing,不会是Begin,这里解决的问题应该只是saga模式下metrics没有打Committed点的问题

@wt-better
Copy link
Contributor

这是特意做的延迟删除,在非at模式下会set一个内存的status让committed打点成功,saga这块漏掉了,你可以提个pr来修复这个问题吗? image

请教下,这里的延迟删除指的是延迟删除Brach事务吧,理论上不应该io.seata.server.session.SessionHelper#endCommitted改这块吧~

@tuwenlin
Copy link
Contributor

这是特意做的延迟删除,在非at模式下会set一个内存的status让committed打点成功,saga这块漏掉了,你可以提个pr来修复这个问题吗? image

请教下,这里的延迟删除指的是延迟删除Brach事务吧,理论上不应该io.seata.server.session.SessionHelper#endCommitted改这块吧~

这里的延迟删除是一种兜底策略,延迟删除GlobalSession,防止有残留的锁和Branch在GlobalSession被删除后没有全局事务关联他们,导致这些残留的锁和Branch一直存在

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment