Skip to content

Add a special plan type for impossible queries#4510

Merged
sougou merged 1 commit intovitessio:masterfrom
eeSeeGee:young.20190209.impossible_plan
Jan 26, 2019
Merged

Add a special plan type for impossible queries#4510
sougou merged 1 commit intovitessio:masterfrom
eeSeeGee:young.20190209.impossible_plan

Conversation

@eeSeeGee
Copy link
Copy Markdown
Contributor

@eeSeeGee eeSeeGee commented Jan 9, 2019

This fixes an annoying case where a missed lookup will spam a single shard with the same impossible query over and over, because the gate doesn't cache columns.

Signed-off-by: Aaron Young young@squareup.com

@eeSeeGee eeSeeGee requested a review from sougou as a code owner January 9, 2019 17:18
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's possible for Fields to be nil for cases where there are bind vars in the select expressions. Code path is here: https://github.com/vitessio/vitess/blob/master/go/vt/vttablet/tabletserver/planbuilder/query_gen.go#L36. In that case we should still send the impossible query to mysql and return those results.

Strangely, I only see an endtoend test for this here: https://github.com/vitessio/vitess/blob/master/go/vt/vttablet/endtoend/queries_test.go#L454. There should ideally be a unit test for this in query_executor_test.go.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hm, I thought I handled that by treating PlanSelectImpossible as a normal select downstream, but will look into this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We've had a policy that DeepEqual shouldn't be used in the query serving path. This is because its cost is unpredictable. However, I'll be open to arguments about why it makes sense in this particular case. Let me know what you think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was just trying to be a good oss citizen by adding support for any impossible query users might throw out, in this case I can just unroll the check to something more robust.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As mentioned above, we'll need a test for the select :bv from t where 1 != 1 case.

@eeSeeGee eeSeeGee force-pushed the young.20190209.impossible_plan branch 2 times, most recently from af27948 to 9c8a4b7 Compare January 24, 2019 20:59
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Backing out the fix in this PR makes another query show up here, which is nice to see.

@sougou
Copy link
Copy Markdown
Contributor

sougou commented Jan 25, 2019

The tests don't look happy.

@eeSeeGee
Copy link
Copy Markdown
Contributor Author

The tests don't look happy.

Hm, not sure what's going on there.

Signed-off-by: Aaron Young <young@squareup.com>
@eeSeeGee eeSeeGee force-pushed the young.20190209.impossible_plan branch from 9c8a4b7 to 023f62e Compare January 25, 2019 04:50
@sougou sougou merged commit 869543a into vitessio:master Jan 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants