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/core: pushdown TiFlash store type check to ColumnToProto #55463

Merged
merged 5 commits into from
Aug 19, 2024

Conversation

joechenrh
Copy link
Contributor

@joechenrh joechenrh commented Aug 16, 2024

What problem does this PR solve?

Issue Number: close #55462

What changed and how does it work?

As described in #55462, the infoschema checker has found inconsistent with v1 and v2 in TestDisaggregatedTiFlashGeneratedColumn, thus throw a panic.

This is because the column info returned from getOriginalPhysicalTableScan is modifed here:

if ts.StoreType == kv.TiFlash {
for _, col := range ts.Columns {
if col.IsVirtualGenerated() {
col.AddFlag(mysql.GeneratedColumnFlag)
}
}
}

As described in the comments, we should do this check in ColumnToProto to avoid ColumnInfo changes.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. sig/planner SIG: Planner labels Aug 16, 2024
Copy link

tiprow bot commented Aug 16, 2024

Hi @joechenrh. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.7948%. Comparing base (2045418) to head (d95c69e).
Report is 24 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55463        +/-   ##
================================================
+ Coverage   73.0142%   75.7948%   +2.7805%     
================================================
  Files          1576       1577         +1     
  Lines        440774     442138      +1364     
================================================
+ Hits         321828     335118     +13290     
+ Misses        99264      86489     -12775     
- Partials      19682      20531       +849     
Flag Coverage Δ
integration 50.8466% <72.2222%> (?)
unit 71.9321% <94.4444%> (-0.1649%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 63.1215% <ø> (+17.1243%) ⬆️

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 19, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 19, 2024
Copy link

ti-chi-bot bot commented Aug 19, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-19 07:55:07.459631219 +0000 UTC m=+165702.594081340: ☑️ agreed by wjhuang2016.
  • 2024-08-19 07:56:07.478575828 +0000 UTC m=+165762.613025945: ☑️ agreed by fzzf678.

@fzzf678
Copy link
Contributor

fzzf678 commented Aug 19, 2024

/retest-required

Copy link

ti-chi-bot bot commented Aug 19, 2024

@fzzf678: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

tiprow bot commented Aug 19, 2024

@fzzf678: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test fast_test_tiprow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@fzzf678
Copy link
Contributor

fzzf678 commented Aug 19, 2024

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Aug 19, 2024
@ti-chi-bot ti-chi-bot bot added the approved label Aug 19, 2024
@AilinKid
Copy link
Contributor

/test check-dev2

Copy link

tiprow bot commented Aug 19, 2024

@AilinKid: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@winoros
Copy link
Member

winoros commented Aug 19, 2024

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 19, 2024
@winoros
Copy link
Member

winoros commented Aug 19, 2024

 if ts.StoreType == kv.TiFlash { 
 	for _, col := range ts.Columns { 
 		if col.IsVirtualGenerated() { 
 			col.AddFlag(mysql.GeneratedColumnFlag) 
 		} 
 	} 
 } 

image
This flag is the one only used in the execution phase and especially the MPP phase.
So we can move it to the phase converting plan to pb. Instead of adding a Clone method that affects all SQLs.\

And, changing ColumnInfo during plan phase is a dangerous operation. Don't do it.
image

@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 19, 2024
@winoros
Copy link
Member

winoros commented Aug 19, 2024

// ColumnToProto converts model.ColumnInfo to tipb.ColumnInfo.
func ColumnToProto(c *model.ColumnInfo, forIndex bool) *tipb.ColumnInfo {
	pc := &tipb.ColumnInfo{
		ColumnId:  c.ID,
		Collation: collate.RewriteNewCollationIDIfNeeded(int32(mysql.CollationNames[c.GetCollate()])),
		ColumnLen: int32(c.GetFlen()),
		Decimal:   int32(c.GetDecimal()),
		Flag:      int32(c.GetFlag()),
		Elems:     c.GetElems(),
	}
	if forIndex {
		// Use array type for read the multi-valued index.
		pc.Tp = int32(c.FieldType.ArrayType().GetType())
		if c.FieldType.IsArray() {
			// Use "binary" collation for read the multi-valued index. Most of the time, the `Collation` of this hidden
			// column should already been set to "binary". However, in old versions, the collation is set to the default
			// value. See https://github.com/pingcap/tidb/issues/46717
			pc.Collation = int32(mysql.CollationNames["binary"])
		}
	} else {
		pc.Tp = int32(c.GetType())
	}
	return pc
}

You can do the same thing as the forIndex. You don't need to clone the model.ColumnInfo, you just need to fix it for the tipb.ColumnInfo.

@joechenrh joechenrh changed the title planner/core: use cloned column infos in getOriginalPhysicalTableScan planner/core: pushdown TiFlash store type check to ColumnToProto Aug 19, 2024
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 19, 2024
Copy link

ti-chi-bot bot commented Aug 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, CbcWestwolf, fzzf678, wjhuang2016

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@winoros
Copy link
Member

winoros commented Aug 19, 2024

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 19, 2024
@ti-chi-bot ti-chi-bot bot merged commit 559f634 into pingcap:master Aug 19, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

infoschema v1 and v2 are inconsistent during TestDisaggregatedTiFlashGeneratedColumn
6 participants