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

planner: use a deep copy for accessPath when clone DataSource (#13620) #13628

Merged
merged 6 commits into from
Nov 20, 2019

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Nov 20, 2019

cherry-pick #13620 to release-3.0


What problem does this PR solve?

Before this PR:

mysql> create table t(a int, b int)partition by range columns(a)(partition p0 values less than (10), partition p1 values less than(20), partition p2 values less than(30));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values (21, 1), (22, 2), (23, 3), (24, 4), (15, 5);
Query OK, 5 rows affected (0.01 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> analyze table t;
Query OK, 0 rows affected (0.01 sec)

mysql> explain select * from t;
+------------------------+----------+-----------+--------------------------------------------------------------------------+
| id                     | count    | task      | operator info                                                            |
+------------------------+----------+-----------+--------------------------------------------------------------------------+
| Union_8                | 10005.00 | root      |                                                                          |
| ├─TableReader_10       | 4.00     | root      | data:TableScan_9                                                         |
| │ └─TableScan_9        | 4.00     | cop[tikv] | table:t, partition:p0, range:[-inf,+inf], keep order:false, stats:pseudo |
| ├─TableReader_12       | 1.00     | root      | data:TableScan_11                                                        |
| │ └─TableScan_11       | 1.00     | cop[tikv] | table:t, partition:p1, range:[-inf,+inf], keep order:false               |
| └─TableReader_14       | 4.00     | root      | data:TableScan_13                                                        |
|   └─TableScan_13       | 4.00     | cop[tikv] | table:t, partition:p2, range:[-inf,+inf], keep order:false               |
+------------------------+----------+-----------+--------------------------------------------------------------------------+
7 rows in set (0.00 sec)

After this PR:

        "SQL": "explain select * from t",
        "Result": [
          "Union_8 10005.00 root ",
          "├─TableReader_10 10000.00 root data:TableScan_9",
          "│ └─TableScan_9 10000.00 cop[tikv] table:t, partition:p0, range:[-inf,+inf], keep order:false, stats:pseudo",
          "├─TableReader_12 1.00 root data:TableScan_11",
          "│ └─TableScan_11 1.00 cop[tikv] table:t, partition:p1, range:[-inf,+inf], keep order:false",
          "└─TableReader_14 4.00 root data:TableScan_13",
          "  └─TableScan_13 4.00 cop[tikv] table:t, partition:p2, range:[-inf,+inf], keep order:false"
        ]

What is changed and how it works?

When processing partition tables, we use a shallow copy for DataSouces. But accessPaths in DataSouces will be changed after that. So we need a deep copy here.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Fix partition table use wrong stats info in physical optimization.

@sre-bot
Copy link
Contributor Author

sre-bot commented Nov 20, 2019

/run-all-tests

@sre-bot sre-bot added sig/planner SIG: Planner type/3.0 cherry-pick type/bugfix This PR fixes a bug. labels Nov 20, 2019
@francis0407 francis0407 added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label Nov 20, 2019
Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added the status/can-merge Indicates a PR has been approved by a committer. label Nov 20, 2019
@sre-bot
Copy link
Contributor Author

sre-bot commented Nov 20, 2019

/run-all-tests

@sre-bot sre-bot merged commit 4f80e0c into pingcap:release-3.0 Nov 20, 2019
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/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants