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

Skip to content

Conversation

@capthua
Copy link
Contributor

@capthua capthua commented Jul 24, 2023

…ith the case in the table metadata, resulting in a rollback failure

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

修复:AT模式,在某些情况下,业务sql中主键字段名大小写与表元数据中的不一致,导致回滚失败

Ⅱ. Does this pull request fix one issue?

fixes #5734

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

…ith the case in the table metadata, resulting in a rollback failure
@CLAassistant
Copy link

CLAassistant commented Jul 24, 2023

CLA assistant check
All committers have signed the CLA.

@capthua
Copy link
Contributor Author

capthua commented Jul 24, 2023

发生回滚异常的场景:

  1. 业务 insert,update sql中包含主键列,且主键列名大小写与表元数据中的列名大小写不一致时。(表元数据中的列名大小写与表定义中的一致)。
  2. MySQL Server版本为 8.0.24,或者数据库连接中参数useOldAliasMetadataBehavior的值为true时,
  3. onlyCareUpdateColumns参数为true(默认值)
    当以上条件全部满足时,回滚失败
    原因:
    创建镜像时,select 中的主键字段名大小写与业务sql中一致,查询结果集的 columnName 大小写与select 中字段的大小写一致, 这时查出来的主键的列名与表元数据中主键列名大小不一致,导致镜像中 record.field 记录中的 keyType 无法标记为 PRIMARY_KEY,从而后面回滚时拼接的sql语句不完整而报错,回滚失败
    image
    image
    image

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 type: bug Category issues or prs related to bug. mode: AT AT transaction mode module/rm-datasource rm-datasource module module/sqlparser sql-parser module labels Jul 31, 2023
@funky-eyes funky-eyes merged commit 66f20a6 into apache:2.x Jul 31, 2023
@capthua capthua deleted the bugfix-2.x branch September 8, 2023 05:33
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
…ith the case in the table metadata, resulting in a rollback failure (apache#5748)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mode: AT AT transaction mode module/rm-datasource rm-datasource module module/sqlparser sql-parser module type: bug Category issues or prs related to bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpringBoot版本2.7,Seata版本1.7.0,AT事务回滚失败问题

4 participants