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

*: refactoring the code of batchChecker #12099

Closed
wants to merge 1 commit into from

Conversation

tiancaiamao
Copy link
Contributor

batchChecker is difficult to maintain, we should get rid of it.
In this commit I catch the BatchGet result into the snapshot, in this way we can
achieve the same goal as the batchChecker

What problem does this PR solve?

The batchChecker is difficult to maintain. It's fragile, full of bugs, we should get rid of it.

CREATE TABLE `t` (
  `a` int(11) NOT NULL,
  `b` int(11) NOT NULL,
  `c` int(11) DEFAULT NULL,
  `d` int(11) DEFAULT NULL,
  `e` int(11) DEFAULT NULL,
  PRIMARY KEY (`a`,`b`),
  UNIQUE KEY `b` (`b`,`c`,`d`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE ( `b` ) (
  PARTITION p0 VALUES LESS THAN (4),
  PARTITION p1 VALUES LESS THAN (7),
  PARTITION p2 VALUES LESS THAN (11)
) ;

insert into t values (1,2,3,4,5);
insert into t values (1,2,3,4,5),(6,2,3,4,6) on duplicate key update e = e + values(e);

Expect:

mysql> select * from t;
+---+---+------+------+------+
| a | b | c    | d    | e    |
+---+---+------+------+------+
| 1 | 2 |    3 |    4 |   16 |
+---+---+------+------+------+
1 row in set (0.00 sec)

Get:

mysql> select * from t;
+---+---+------+------+------+
| a | b | c    | d    | e    |
+---+---+------+------+------+
| 1 | 2 |    3 |    4 |   11 |
+---+---+------+------+------+
1 row in set (0.00 sec)

What is changed and how it works?

The first step: do not use it.
The second step: clean up the code.

In this commit, I re-implement the insert ... on duplicate key update ... without using the batchChecker.
And I also implement a cache mechanism in the snapshot and the BatchGet API, so the performance should not change.

Check List

Tests

  • Unit test (WIP)

Side effects

  • Possible performance regression

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Write release note for bug-fix or new feature.

Fix bugs of insert ... on duplicate update on the partitioned table

batchChecker is difficult to maintain, we should get rid of it.
In this commit I catch the BatchGet result into the snapshot, in this way we can
achieve the same goal as the batchChecker
@tiancaiamao tiancaiamao added type/enhancement The issue or PR belongs to an enhancement. status/WIP type/bugfix This PR fixes a bug. require-LGT3 Indicates that the PR requires three LGTM. sig/execution SIG execution labels Sep 9, 2019
@tiancaiamao
Copy link
Contributor Author

PTAL @jackysp

@tiancaiamao
Copy link
Contributor Author

I pushed to the wrong branch.
See this one #12108

@tiancaiamao tiancaiamao deleted the refactor-batch-checker branch September 10, 2019 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
require-LGT3 Indicates that the PR requires three LGTM. sig/execution SIG execution type/bugfix This PR fixes a bug. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant