seata的hook优化建议

ca1c2owp  于 22天前  发布在  其他
关注(0)|答案(5)|浏览(16)

我们项目组使用了seata1.5.2版本,在研发seata监控的时候,用到了TM的HOOK机制,但是在使用上发现一些问题

  1. 同一个线程中出现多个@GlobalTransactional,每个@GlobalTransactional都会执行钩子方法,不论是TM的发起者还是参与者,很多时候我们只需要发起者执行钩子方法,不需要参与者执行钩子,这里根本无法进行判断区分
  2. 同一个线程的最后一个@GlobalTransactional在执行完afterCompletion后会将注册的hook对象删除(cleanUp方法),导致其他@GlobalTransactional无法成功执行hook后处理方法

优化建议:

  1. 优化钩子方法(beforeBegin、afterBegin、beforeCommit、afterCommit、beforeRollback、afterRollback、afterCompletion)
    所有钩子方法新增入参GlobalTransaction tx,这样就能判断到底是发起者还是参与者调用了
  2. 在TransactionalTemplate执行完commit/rollback之后,会进行cleanUp操作(删除hook对象),这个不太合理,这里希望能用java-spi的方式重写cleanUp方法,并且cleanUp方法新增入参GlobalTransaction tx,这样我们就能对cleanUp进行重写(spi的方式)
0ve6wy6x

0ve6wy6x1#

@412165137lzh I agree with your idea. Could you submit a pr to optimize it ?

68bkxrlz

68bkxrlz2#

#5073 The second point is consistent with this issue

6ojccjat

6ojccjat3#

#5073 The second point is consistent with this issue

get it

wgxvkvu9

wgxvkvu94#

@412165137lzh I agree with your idea. Could you submit a pr to optimize it ?

thx,I will submit later when I am free

6l7fqoea

6l7fqoea5#

#4555 我之前做过xid的,但斌哥好像有其他考虑然后说搁置了, @funky-eyes

相关问题