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

executor: fix a bug of 'insert on duplicate update' statement on partitioned table #11204

Merged
merged 3 commits into from
Jul 11, 2019

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

create table t2 (a int,b int,primary key(a,b)) partition by hash(a) partitions 4;
create table t1 (a int,b int,primary key(a,b)) partition by range(a) (partition p0 values less than (100),partition p1 values less than (1000));
insert into t1 set a=1,b=1;
insert into t2 set a=1,b=1;
insert into t1 set a=1,b=1 on duplicate key update a=1,b=1;
(1105, u'can not be duplicated row, due to old row not found. handle 1 not found')
insert into t2 set a=1,b=1 on duplicate key update a=1,b=1;
(1105, u'can not be duplicated row, due to old row not found. handle 1 not found')

In this statement:

insert into t1 set a=1,b=1 on duplicate key update a=1,b=1

Batch checker find a=1,b=1 is duplicated, then in the "on duplicate update" step,
it uses the non-partitioned table to get the old row, which is a bug.
getOldRow returns this error: (1105, u'can not be duplicated row, due to old row not found. handle 1 not found')

What is changed and how it works?

Use the partitioned table to getOldRow

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

…itioned table

In this statement: insert into t1 set a=1,b=1 on duplicate key update a=1,b=1
Batch checker find a=1,b=1 is duplicated, then in the "on duplicate update" step,
it use non-partitioned table to get the old row, which is a bug.
getOldRow returns this error: (1105, u'can not be duplicated row, due to old row not found. handle 1 not found')
@tiancaiamao tiancaiamao added type/bugfix This PR fixes a bug. priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/execution SIG execution needs-cherry-pick-3.0 labels Jul 11, 2019
@tiancaiamao
Copy link
Contributor Author

PTAL @crazycs520 @jackysp

@codecov
Copy link

codecov bot commented Jul 11, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@2ea24e0). Click here to learn what that means.
The diff coverage is 100%.

@@             Coverage Diff             @@
##             master     #11204   +/-   ##
===========================================
  Coverage          ?   81.2743%           
===========================================
  Files             ?        423           
  Lines             ?      90005           
  Branches          ?          0           
===========================================
  Hits              ?      73151           
  Misses            ?      11557           
  Partials          ?       5297

@codecov
Copy link

codecov bot commented Jul 11, 2019

Codecov Report

Merging #11204 into master will increase coverage by 0.0164%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11204        +/-   ##
================================================
+ Coverage   81.2468%   81.2632%   +0.0164%     
================================================
  Files           423        423                
  Lines         90198      90005       -193     
================================================
- Hits          73283      73141       -142     
+ Misses        11612      11563        -49     
+ Partials       5303       5301         -2

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

crazycs520
crazycs520 previously approved these changes Jul 11, 2019
Copy link
Contributor

@crazycs520 crazycs520 left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor Author

/run-all-tests

@tiancaiamao tiancaiamao merged commit 9385c6e into pingcap:master Jul 11, 2019
@tiancaiamao tiancaiamao deleted the partition-insert-on-duplicate branch July 11, 2019 07:24
tiancaiamao added a commit to tiancaiamao/tidb that referenced this pull request Jul 12, 2019
…itioned table (pingcap#11204)

In this statement: insert into t1 set a=1,b=1 on duplicate key update a=1,b=1
Batch checker find a=1,b=1 is duplicated, then in the "on duplicate update" step,
it uses the non-partitioned table to get the old row, which is a bug.
getOldRow returns this error: (1105, u'can not be duplicated row, due to old row not found. handle 1 not found')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/execution SIG execution type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants