Skip to content

Conversation

@jonasHanhan
Copy link
Contributor

@jonasHanhan jonasHanhan commented Mar 1, 2024

… clears them.

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

bugfix: fix the bug where Role.participant does not execute hooks but clears them.

Ⅱ. Does this pull request fix one issue?

fixes #6384

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2024

Codecov Report

❌ Patch coverage is 13.63636% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.93%. Comparing base (575ac12) to head (5b8a892).
⚠️ Report is 421 commits behind head on 2.x.

Files with missing lines Patch % Lines
...ga/engine/store/db/DbAndReportTcStateLogStore.java 0.00% 13 Missing ⚠️
...ga/engine/tm/DefaultSagaTransactionalTemplate.java 0.00% 4 Missing ⚠️
...org/apache/seata/tm/api/TransactionalTemplate.java 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6385      +/-   ##
============================================
- Coverage     51.01%   50.93%   -0.08%     
- Complexity     5261     5277      +16     
============================================
  Files           934      937       +3     
  Lines         33029    33145     +116     
  Branches       4002     4019      +17     
============================================
+ Hits          16849    16884      +35     
- Misses        14511    14590      +79     
- Partials       1669     1671       +2     
Files with missing lines Coverage Δ
...org/apache/seata/tm/api/TransactionalTemplate.java 54.69% <60.00%> (-0.37%) ⬇️
...ga/engine/tm/DefaultSagaTransactionalTemplate.java 0.00% <0.00%> (ø)
...ga/engine/store/db/DbAndReportTcStateLogStore.java 0.00% <0.00%> (ø)

... and 10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@funky-eyes funky-eyes added type: bug Category issues or prs related to bug. TM Relate to seata tm module/tm tm module good first issue Good for newcomers labels Mar 1, 2024
@funky-eyes funky-eyes added this to the 2.1.0 milestone Mar 1, 2024
GlobalTransaction globalTransaction;
try {
globalTransaction = getGlobalTransaction(machineInstance, context);
if (globalTransaction == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not unify it in template?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to move the getGlobalTransaction method to the template? If so, it should be a refactoring of the code and should not be done in this commit.
你的意思是把getGlobalTransaction 方法移动到模版里么 如果这样的话应该是对代码的一次重构,不应该在本次提交中完成

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to move the getGlobalTransaction method to the template? If so, it should be a refactoring of the code and should not be done in this commit. 你的意思是把getGlobalTransaction 方法移动到模版里么 如果这样的话应该是对代码的一次重构,不应该在本次提交中完成

我说的是在template中针对传入globaltransactional进行判空,如果是空的应该抛异常提示不允许为null
I'm talking about passing in globaltransactional in the template for null, if it's null it should throw an exception to indicate that it's not allowed to be null.

Copy link
Member

@ptyin ptyin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

private void cleanUp() {
TransactionHookManager.clear();
private void cleanUp(GlobalTransaction tx) {
if (tx == null || tx.getGlobalTransactionRole() == GlobalTransactionRole.Launcher) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does DefaultSagaTransactionalTemplate.java do the processing, but no exception is thrown here?
为什么DefaultSagaTransactionalTemplate.java做了处理,而这里没有进行抛出异常?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private void cleanUp(GlobalTransaction tx) {
    if (tx == null) {
        throw new FrameworkException("Global transaction does not exist. Unable to proceed without a valid global transaction context.",
                FrameworkErrorCode.ObjectNotExists);
    }
    if (tx.getGlobalTransactionRole() == GlobalTransactionRole.Launcher) {
        TransactionHookManager.clear();
    }
}

Is this suitable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have repaired it in this way, please review.

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@funky-eyes funky-eyes added the first-time contributor first-time contributor label Mar 5, 2024
@funky-eyes funky-eyes merged commit b4ea963 into apache:2.x Mar 5, 2024
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor first-time contributor good first issue Good for newcomers module/tm tm module TM Relate to seata tm type: bug Category issues or prs related to bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2.0.0 Role.Participant不执行hook但会清理,导致hook无法执行

4 participants