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

TransactionHook没有被正确clear #6880

Open
1 task
0x9bb1 opened this issue Sep 26, 2024 · 8 comments
Open
1 task

TransactionHook没有被正确clear #6880

0x9bb1 opened this issue Sep 26, 2024 · 8 comments

Comments

@0x9bb1
Copy link

0x9bb1 commented Sep 26, 2024

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

Ⅰ. Issue Description

Ⅱ. Describe what happened

  1. 时刻1开启事务1,线程[http-nio-8089-exec-14]在添加TransactionHook,实现afterRollback方法。事务1成功提交。
  2. 时刻2开启事务2,事务2异常回滚后,线程[http-nio-8089-exec-14]执行了afterRollback方法内逻辑。
Just paste your stack trace here!

Ⅲ. Describe what you expected to happen

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

  1. xxx
  2. xxx
  3. xxx

Minimal yet complete reproducer code (or URL to code):

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

  • JDK version(e.g. java -version):1.8
  • Seata client/server version: 1.3
  • Database version:mysql8.0
  • OS(e.g. uname -a):
  • Others:
@funky-eyes
Copy link
Contributor

#4555

@0x9bb1
Copy link
Author

0x9bb1 commented Sep 26, 2024

#4555

恕我愚钝...这是为hook添加了xid参数,这似乎与我的case关系不大,麻烦再提点一下

@funky-eyes
Copy link
Contributor

#4555

恕我愚钝...这是为hook添加了xid参数,这似乎与我的case关系不大,麻烦再提点一下

通过xid区分不同的hook,就不会因为事务嵌套,导致前者的hook被调用
如果你不是事务嵌套,尝试升级下版本,或者查看release note看看该问题是否已经被修复

@0x9bb1
Copy link
Author

0x9bb1 commented Sep 26, 2024

#4555

恕我愚钝...这是为hook添加了xid参数,这似乎与我的case关系不大,麻烦再提点一下

通过xid区分不同的hook,就不会因为事务嵌套,导致前者的hook被调用 如果你不是事务嵌套,尝试升级下版本,或者查看release note看看该问题是否已经被修复

我不是嵌套,我是tomcat线程复用导致前一事务设置的hook,被后一事务回滚后触发了。我去看看release note

@0x9bb1
Copy link
Author

0x9bb1 commented Sep 26, 2024

我在release note中没有发现有提到该问题的
再补充一些细节,我的case不存在事务嵌套。是同一线程的不同时刻前者事务提交后,不知道为什么hook没有清理,导致下一个事务回滚的时候,将上一个事务放置的hook执行了。
而且本地debug也没有复现,所以没法提供一下最小可复现的case,但是我可以确认存在这种情况
看代码io.seata.spring.annotation.GlobalTransactionalInterceptor#handleGlobalTransaction的finally中确实clear了不知道为什么
后面有遇到相同case的小伙伴麻烦圈一下我

@funky-eyes
Copy link
Contributor

我在release note中没有发现有提到该问题的 再补充一些细节,我的case不存在事务嵌套。是同一线程的不同时刻前者事务提交后,不知道为什么hook没有清理,导致下一个事务回滚的时候,将上一个事务放置的hook执行了。 而且本地debug也没有复现,所以没法提供一下最小可复现的case,但是我可以确认存在这种情况 看代码io.seata.spring.annotation.GlobalTransactionalInterceptor#handleGlobalTransaction的finally中确实clear了不知道为什么 后面有遇到相同case的小伙伴麻烦圈一下我

可以先尝试升级下看看

@0x9bb1
Copy link
Author

0x9bb1 commented Sep 26, 2024

我在release note中没有发现有提到该问题的 再补充一些细节,我的case不存在事务嵌套。是同一线程的不同时刻前者事务提交后,不知道为什么hook没有清理,导致下一个事务回滚的时候,将上一个事务放置的hook执行了。 而且本地debug也没有复现,所以没法提供一下最小可复现的case,但是我可以确认存在这种情况 看代码io.seata.spring.annotation.GlobalTransactionalInterceptor#handleGlobalTransaction的finally中确实clear了不知道为什么 后面有遇到相同case的小伙伴麻烦圈一下我

可以先尝试升级下看看

好的 我这先先升级后观察观察

@slievrly
Copy link
Member

slievrly commented Oct 8, 2024

I have always had a different opinion on this design. I think that the hook should not be thread-local but rather at the method granularity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants