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

optimize: intercept insert on duplicate update statement which has no … #5075

Conversation

renliangyu857
Copy link
Contributor

…primary key and unique index

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

针对主键自增且没有唯一索引值的insert on duplicate语句,由于主键自增值依赖驱动版本情况,需要再测试(#5065),1.6版本先进行拦截。后面的版本再考虑合入(https://github.com/seata/seata/pull/5044)

Ⅱ. Does this pull request fix one issue?

fixes #5007

Ⅲ. 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.

LGTM

@funky-eyes funky-eyes added this to the 1.6.0 milestone Nov 14, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2022

Codecov Report

Merging #5075 (7678421) into develop (32d0ca8) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #5075      +/-   ##
=============================================
- Coverage      49.46%   49.42%   -0.05%     
+ Complexity      4128     4126       -2     
=============================================
  Files            734      734              
  Lines          26058    26061       +3     
  Branches        3221     3220       -1     
=============================================
- Hits           12890    12880      -10     
- Misses         11791    11805      +14     
+ Partials        1377     1376       -1     
Impacted Files Coverage Δ
...ec/mysql/MySQLInsertOnDuplicateUpdateExecutor.java 31.97% <0.00%> (-0.50%) ⬇️
...rage/redis/store/RedisTransactionStoreManager.java 72.06% <0.00%> (-2.09%) ⬇️
...in/java/io/seata/server/session/GlobalSession.java 78.68% <0.00%> (-0.78%) ⬇️
...very/registry/zk/ZookeeperRegisterServiceImpl.java 61.02% <0.00%> (-0.74%) ⬇️
...o/seata/server/coordinator/DefaultCoordinator.java 47.95% <0.00%> (+0.40%) ⬆️

@robynron
Copy link
Contributor

不同数据库,对getGeneratedKeys的返回值,有不同的实现;
对于批量插入语句,提供一些案例:

  • MySQL
  1. getGeneratedKeys返回的主键值,是表中当前最大的主键值 + (1 -> insert的行数)
  2. 批量插入SQL无论是否commit、rollback,其自增主键值都会向上累加insert的行数
  • DRDS
  1. getGeneratedKeys返回的主键值,是表中当前最大的主键值 + (1 -> insert的行数);(同上)
  2. 只有insert操作Commit成功,其自增主键值仅向上累加使用了自动生成的主键的insert操作的行数

例如:

  1. 对于insert into xxx (id,name) values(null,?),(null,?):drds与MySQL的自增主键都会向上累加2;
  2. 对于insert into xxx (id,name) values(not null,?),(null,?):MySQL的自增主键会向上累加2;DRDS仅向上累加1;

Copy link
Contributor

@l81893521 l81893521 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 merged commit 2f1e576 into apache:develop Nov 15, 2022
@funky-eyes funky-eyes changed the title optimize:intercept insert on duplicate update statement which has no … optimize: intercept insert on duplicate update statement which has no … Nov 15, 2022
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

zw201913 pushed a commit to zw201913/seata that referenced this pull request Nov 16, 2022
…o 1114_for_5073

* '1114_for_5073' of https://github.com/zw201913/seata:
  test: test support for arm64 (apache#5069)
  test: add AT transaction mode tests to support database data types (Oracle) (apache#4411)
  bugfix: fix could not intercept the sql witch has no primary and unique (apache#5078)
  optimize: intercept insert on duplicate update statement which has no primary key and unique index (apache#5075)
  optimize: support oracle date types (apache#4542)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants