You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "liyy653787585 (via GitHub)" <gi...@apache.org> on 2024/04/15 08:48:35 UTC
[I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
liyy653787585 opened a new issue, #6480:
URL: https://github.com/apache/incubator-seata/issues/6480
以重试回滚定时任务为例,当满足if (isRetryTimeout(now, MAX_ROLLBACK_RETRY_TIMEOUT.toMillis(), rollbackingSession.getBeginTime()))时,会执行以下代码删除全局事务会话,看注释是为了防止线程安全问题,代码如下:
`// Prevent thread safety issues
SessionHolder.getRetryRollbackingSessionManager().removeGlobalSession(rollbackingSession);`
这种处理可能会带来一个问题,就是当某一个RM执行任务阻塞时,此时TC通过定时任务进行回滚发现超时了,那么就会删除全局事务会话,但是此时对应的分支事务会话还是存在于DB中,并且此时执行xa recover发现xa事务并没有结束,需要手动进行处理。我的疑问是:
1、这里指的线程安全问题是什么?可以详细说下吗?
2、除了直接删除全局事务会话这种方式,还有其他方式可以避免这里的线程安全问题吗?因为我们想在事务失败的时候保留全局事务会话,这样方便后续排查问题。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2060644362
是的,我们之前也发现了类似你提到的问题,所以在高版本上特地做了修改,避免类似事情出现的时候,连个事务去回溯然后人工介入的渠道都没有。那我这个issue就先关闭了哈
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2060572687
1.高版本已经解决了这个问题,这个还归为一个新的bug吗?
2.既然你已经选择了事务重试超时,代表事务不再重试了,你本身就要去人工介入,否则你改这个值意义是什么?就为了掩耳盗铃?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "liyy653787585 (via GitHub)" <gi...@apache.org>.
liyy653787585 commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2060561373
> > > 你不要设置全局事务重试超时时间,就不会出现事务重试超时被删除的问题 You should not set the global transaction retry timeout time, so that the transaction retry timeout will not be deleted.
> >
> >
> > 好的,但是当设置超时时间时,确实会出现上述xa事务没有结束的问题,这个需要我单独提个bug吗?我附上相关截图
>
> 这不是bug,这是你自己选择要删除的。况且高版本并不会删除,因为我们考虑到用这个配置的用户很可能没看过源码,也没理解分布式事务,不知道这个动作的严重后果 This is not a bug, this is what you choose to delete. Moreover, the higher version will not be deleted, because we consider that users with this configuration may not have seen the source code, nor understand the distribution transaction, and do not know the serious consequences of this action
是这样的,经过我的测试发现,这个删除全局事务会话的操作,可能会使RM侧无法正常进行回滚,最终导致xa资源一直无法释放的问题。
大概流程是这样的:
1、全局事务开启,三个RM分别为stock、order、account,其中stock、order一阶段正常结束,account正在执行业务逻辑中(假设account任务比较耗时)
2、TC侧timeoutCheck定时任务扫描到该全局事务会话,发现已超时,此时将该全局事务会话状态由GlobalStatus.Begin修改为GlobalStatus.TimeoutRollbacking
3、TC侧retryRollbacking定时任务扫描到GlobalStatus.TimeoutRollbacking状态的该全局事务会话,发现重试已超时(假设这里手动设置了重试超时时间),那么就会删除该全局事务会话
4、account执行业务逻辑出错,此时TM需要通知TC进行回滚,接着TC发现该全局事务会话已经不存在了(被超时删除了),此时TC返回GlobalStatus.Finished状态就直接结束了,并不会给RM(stock、order)下发回滚的指令,最终导致stock、order的xa资源一直无法释放。
我使用的seata版本是1.6.x,TC侧DefaultCore#rollback方法代码如下:

我是这样理解的,因为seata对外提供了server.maxCommitRetryTimeout、server.maxRollbackRetryTimeout配置参数,虽然默认是一直重试不会超时,但总有人会去修改超时时间的,这个是避免不了的,那么当设置了超时时间后,就会删除全局事务会话,进而可能会导致xa资源一直无法释放,这个应该属于bug吧?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2058279067
你不要设置全局事务重试超时时间,就不会出现事务重试超时被删除的问题
You should not set the global transaction retry timeout time, so that the transaction retry timeout will not be deleted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "liyy653787585 (via GitHub)" <gi...@apache.org>.
liyy653787585 commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2058139612
> 默认全局事务的重试不会超时,如果你设置了超时时间 高版本中当超时时间达到时,会修改状态为failed,然后不再进行重试。 低版本则会删除这个全局事务。 你说的xa问题升级到1.5.2及以上基本上不会有此类问题出现,也不太可能出现此类问题的事务悬挂
非常感谢您的回答,我目前使用的seata版本是1.6.x,设置了超时时间,昨天测试的时候,确实发生了上边的问题,我现在有两个疑问:
1、我看了seata高版本2.X的代码,确实没有删除全局事务会话,但是我想搞明白为什么低版本会这样处理?这里的线程安全问题具体指的是什么?
2、如果我想在低版本1.6.x中保留全局事务会话,这个线程安全问题有没有其他解决方案?
期待您的回答
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "liyy653787585 (via GitHub)" <gi...@apache.org>.
liyy653787585 commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2058369917
> 你不要设置全局事务重试超时时间,就不会出现事务重试超时被删除的问题 You should not set the global transaction retry timeout time, so that the transaction retry timeout will not be deleted.
好的,但是当设置超时时间时,确实会出现上述xa事务没有结束的问题,这个需要我单独提个bug吗?我附上相关截图
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2060168172
> > 你不要设置全局事务重试超时时间,就不会出现事务重试超时被删除的问题 You should not set the global transaction retry timeout time, so that the transaction retry timeout will not be deleted.
>
> 好的,但是当设置超时时间时,确实会出现上述xa事务没有结束的问题,这个需要我单独提个bug吗?我附上相关截图
这不是bug,这是你自己选择要删除的。况且高版本并不会删除,因为我们考虑到用这个配置的用户很可能没看过源码,也没理解分布式事务,不知道这个动作的严重后果
This is not a bug, this is what you choose to delete. Moreover, the higher version will not be deleted, because we consider that users with this configuration may not have seen the source code, nor understand the distribution transaction, and do not know the serious consequences of this action
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes closed issue #6480: 关于TC重试任务删除全局事务会话问题
URL: https://github.com/apache/incubator-seata/issues/6480
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2058121757
默认全局事务的重试不会超时,如果你设置了超时时间
高版本中当超时时间达到时,会修改状态为failed,然后不再进行重试。
低版本则会删除这个全局事务。
你说的xa问题升级到1.5.2及以上基本上不会有此类问题出现,也不太可能出现此类问题的事务悬挂
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "liyy653787585 (via GitHub)" <gi...@apache.org>.
liyy653787585 commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2060636191
> 1.高版本已经解决了这个问题,这个还归为一个新的bug吗? 2.既然你已经选择了事务重试超时,代表事务不再重试了,你本身就要去人工介入,否则你改这个值意义是什么?就为了掩耳盗铃?
从你讲的这个角度去理解,逻辑自洽,确实没毛病,感谢指教。可能是我太抓细节了,一直认为直接删除全局事务会话的方式不合理,回头来看,最多算是1.6.x实现的不够优雅而已,再次感谢。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "liyy653787585 (via GitHub)" <gi...@apache.org>.
liyy653787585 commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2060743072
> 是的,我们之前也发现了类似你提到的问题,所以在高版本上特地做了修改,避免类似事情出现的时候,连个事务去回溯然后人工介入的渠道都没有。那我这个issue就先关闭了哈
再咨询个问题哈,我翻了一下git提交记录,发现是在 #5298 中完成了修复,而修复方案只是将SessionHolder.getRootSessionManager().removeGlobalSession(rollbackingSession)这行代码给删除了。
我的问题是:如果我想在1.6.x中修复该问题,是不是只需要将SessionHolder.getRootSessionManager().removeGlobalSession(rollbackingSession)这行代码删除就可以了?因为我注意到这行代码的注释为“Prevent thread safety issues”,所以担心删除这行代码后会带来新的问题,那么我在修复的时候,除了删除上边这行代码,还需要修改其他地方吗?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [I] 关于TC重试任务删除全局事务会话问题 [incubator-seata]
Posted by "liyy653787585 (via GitHub)" <gi...@apache.org>.
liyy653787585 commented on issue #6480:
URL: https://github.com/apache/incubator-seata/issues/6480#issuecomment-2060667944
> 是的,我们之前也发现了类似你提到的问题,所以在高版本上特地做了修改,避免类似事情出现的时候,连个事务去回溯然后人工介入的渠道都没有。那我这个issue就先关闭了哈
嗯,关闭吧,我现在遇到的问题就是,人工介入渠道的缺失,只能手动执行xa recover/rollback去恢复,因为全局事务会话已经被删除了,后期找机会升级到2.0吧
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org