Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Bughue
Copy link
Contributor

@Bughue Bughue commented May 22, 2023

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

在事务传播过程中,如果出现Participant的情况(比如required或者support的),就会加入已存在的事务,当前逻辑在这种情况的处理存在不完善。

  • 大部分情况下,核心逻辑和主要的日志写在DefaultGlobalTransaction类中,而hook处理在TransactionalTemplate(比如begin的逻辑)由于role判断写在DefaultGlobalTransaction所以没问题
  • 但对于commit和rollback,日志先写在了TransactionalTemplate,没有进行role判断,所以切面第二次进入切面后TransactionalTemplate里的逻辑先不管role就打印了日志,然后进行hook,等进入DefaultGlobalTransaction后又判断了role所以其实并没有执行真正的commit/rollback。

目前的改造方式

  • 把这两个关键的日志移动回DefaultGlobalTransaction内部,也就是判断完role再打印
  • 优化TransactionalTemplate,日志移除,并在switch阶段就把current transaction处理干净
  • hook的逻辑没有发生变化,多次进入切面依然会多次执行

不足之处讨论

  • hook多次执行:加入事务在DefaultGlobalTransaction内会直接返回,但hook会再次执行,逻辑上有点奇怪,以后的改造建议是participant的情况在TransactionalTemplate就跳过去,就像斌哥说的这种情况打个日志直接execute
  • 兼容性顾虑:因为按现在的逻辑加入事务也会触发hook,如果我们真的改了,用户升级时是没有感知的,如果他之前真的依赖这个hook去做重要的事情,可能带来问题
  • 其他:移除的日志现在只是注释,如果大家觉得这个改动方式没问题,我会再提交一次把他删掉

Ⅱ. Does this pull request fix one issue?

fixes #5567

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

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.

第2点的话,应该是REQUIRED,MANDATORY,SUPPORTS这几种才是直接执行execute,除REQUIRED已经都这么处理了,就REQUIRED是break走到下面,没有判断是否已经存在xid了,所以第二点担心的hook问题,在同一个xid下hook本身就是正确的,以及现在在事务传播中还存在hookbug,比如REQUIRED_NEW,会执行前面那个xid的hook #5076 这个pr修了这个问题,所以第二点应该是不存在这个问题的,每个xid对应自己的hook能执行即可

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.

可以先按这个pr的做法来,将commit和rollback的日志挪到更下层的defaultglobaltransaction类中,避免重复进入template的commit和rollback方法,后续我觉得可以优化下REQUIRED的处理

@funky-eyes
Copy link
Contributor

/home/runner/work/seata/seata/tm/src/main/java/io/seata/tm/api/TransactionalTemplate.java:89: Not allow chinese character ! [RegexpSingleline]

Copy link
Contributor

@wangliang181230 wangliang181230 left a comment

Choose a reason for hiding this comment

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

LGTM,修改一下 changelog.md 吧。

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 this to the 2.0.0 milestone May 23, 2023
@funky-eyes funky-eyes added type: bug Category issues or prs related to bug. module/tm tm module labels May 23, 2023
@funky-eyes funky-eyes changed the title bugfix : fix log in participant transaction role bugfix: fix log in participant transaction role May 23, 2023
@funky-eyes funky-eyes merged commit b2d4584 into apache:2.x May 23, 2023
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

LGTM

Pil0tXia pushed a commit to Pil0tXia/seata that referenced this pull request Jun 14, 2023
my change 2

optimize: optimize channel availability thread log output (apache#5563)

feature:docker image supports JVM parameter injection (apache#5529)

test: add unit test for transaction messages (apache#5637)

feature: support trace the transaction link according to the XID (apache#5600)

test: add unit test case for ExporterType/RegistryType (apache#5622)

optimize: possible conflict between asyncCommitting thread and retryCommitting thread (apache#5623)

optimize: possible conflict between asyncCommitting thread and retryCommitting thread (apache#5623)

optimize: support case-sensitive attributes for table and column metadata (apache#5553) (+14 squashed commit)

Squashed commit:

[c97f409] mychange 1

my change 2

optimize: optimize channel availability thread log output (apache#5563)

feature:docker image supports JVM parameter injection (apache#5529)

test: add unit test for transaction messages (apache#5637)

feature: support trace the transaction link according to the XID (apache#5600)

test: add unit test case for ExporterType/RegistryType (apache#5622)

[8f9bba2] bugfix: fix the `asyncCommit` and `queueToRetryCommit` always failed in db mode (apache#5604)

[b2d4584] bugfix: fix log in participant transaction role (apache#5594)

[d0d012c] feature: support sqlserver in AT mode (apache#3887)

[54bd3ca] feature:support MS SqlServer on the server side of AT mode (apache#4033)

[d1e6e6b] bugfix: grpc interceptor xid unbinding problem (apache#5577)

[0b49e06] optimize: The common fence clean task is only initiated when useTCCFence is set to true (apache#5576)

[7e40e05] bugfix: fix mariadb rollback failed (apache#5558)

[ee1ecf7] bugfix: fix oracle insert undolog failed (apache#5556)

Signed-off-by: slievrly <[email protected]>

[0a1edf3] optimize: update expire gpg key and publish workflow (apache#5549)

Signed-off-by: slievrly <[email protected]>

[1c8e4bf] bugfix: the log file path was loaded incorrectly (apache#5531)

[c73d72d] bugfix: fix GlobalStatus=9 can't be cleared in DB storage mode (apache#5523)

[83493d9] optimize: optimize FenceHandler for oracle (apache#5519)

[9b35ba9] bugfix: fix the full table scan issue with 'setDate' condition in Oracle 10g (apache#5498)
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

module/tm tm module type: bug Category issues or prs related to bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeated output of transaction resolution logs

4 participants