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: do not push keep descending order to tiflash #13572

Merged
merged 9 commits into from
Dec 2, 2019

Conversation

lzmhhh123
Copy link
Contributor

What problem does this PR solve?

As the title says.

What is changed and how it works?

When do skyline pruning, check the properties for TiFlash access path.

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Possible performance regression
  • Increased code complexity

@lzmhhh123 lzmhhh123 added type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Nov 19, 2019
@codecov
Copy link

codecov bot commented Nov 19, 2019

Codecov Report

Merging #13572 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #13572   +/-   ##
===========================================
  Coverage   80.4764%   80.4764%           
===========================================
  Files           474        474           
  Lines        118457     118457           
===========================================
  Hits          95330      95330           
  Misses        15746      15746           
  Partials       7381       7381

@@ -428,6 +429,7 @@ func (ds *DataSource) setPreferredStoreType(hintInfo *tableHintInfo) {
}
if hintInfo.ifPreferTiFlash(alias) {
ds.preferStoreType |= preferTiFlash
ds.possibleAccessPaths = append(ds.possibleAccessPaths, &accessPath{isTablePath: true, storeType: kv.TiFlash})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do it when build possibleAccessPaths? From the function name, it should not change access paths.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the TiFlash replica is not available. We can't generate a flash access path. But when the hint is set. we should enforce a flash access path.

Copy link
Member

Choose a reason for hiding this comment

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

This is a temp behavior since we choose tiflash only by hint currently?
After we can choose tiflash by default, we don't need to add it here?
You can add a TODO here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@winoros That's not a temp behavior. For now, CBO can judge whether to choose the TiFlash access path by tblInfo.TiFlashReplica.Available. I hope when users set the hint, the planner enforce a TiFlash path without check the TiFlash replica status.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hint should not enforce something that tidb cannot do, it is only a suggestion for optimizer. Therefore, if the tiflash access path is not available, optimizer should not use it even if there are hints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's a normal performance. But I still want to leave a function to force accessing the TiFlash. It's easy for both PD and TiFlash to check the bug when the replica is unavailable.

Copy link
Contributor

Choose a reason for hiding this comment

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

There would be 2 TiFlash paths then? since getPossibleAccessPaths may has appended one already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but it doesn't affect the correctness. Just make the planner a bit slower.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to check if TiFlash path exists before adding a new one. Also, please add comment to explain that this change is for testing purpose, and add a TODO to remind reverting it finally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to check if TiFlash path exists before adding a new one. Also, please add comment to explain that this change is for testing purpose, and add a TODO to remind reverting it finally.

@eurekaka Done.

planner/core/logical_plan_builder.go Outdated Show resolved Hide resolved
planner/core/find_best_task.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

@alivxxx alivxxx added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 27, 2019
}
if ds.preferStoreType&preferTiKV != 0 && path.storeType == kv.TiFlash {
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We may end up with no plan generated if the hint specifies TiFlash while there is no TiFlash replica available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, if there is no TiFlash replica available, we still force a TiFlash plan.

@@ -428,6 +429,7 @@ func (ds *DataSource) setPreferredStoreType(hintInfo *tableHintInfo) {
}
if hintInfo.ifPreferTiFlash(alias) {
ds.preferStoreType |= preferTiFlash
ds.possibleAccessPaths = append(ds.possibleAccessPaths, &accessPath{isTablePath: true, storeType: kv.TiFlash})
Copy link
Contributor

Choose a reason for hiding this comment

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

There would be 2 TiFlash paths then? since getPossibleAccessPaths may has appended one already.

@sre-bot
Copy link
Contributor

sre-bot commented Dec 1, 2019

@lamxTyler, @winoros, @eurekaka, @francis0407, PTAL.

@eurekaka eurekaka removed their request for review December 2, 2019 03:12
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

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

sre-bot commented Dec 2, 2019

/run-all-tests

@sre-bot sre-bot merged commit de862fc into pingcap:master Dec 2, 2019
@lzmhhh123 lzmhhh123 deleted the dev/ban_descent_tiflash branch December 2, 2019 06:05
XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
lzmhhh123 added a commit to lzmhhh123/tidb that referenced this pull request Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants