apache / apache/incubator-seata
seata的hook优化建议
- Dominant language
- Java
- Stars
- 26k
- Forks
- 8.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
我们项目组使用了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的方式)
Contributor guide
Research direction
Start with TransactionalTemplate and the TM hook lifecycle, including beforeBegin, afterBegin, commit, rollback, afterCompletion, and cleanUp. Trace how hooks are invoked and removed for nested GlobalTransaction instances, then define completion criteria for transaction context parameters and an SPI-overridable cleanup path; no test or file path is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100