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

store/tikv: sort keys in batch get #25416

Merged
merged 2 commits into from
Jun 15, 2021

Conversation

youjiali1995
Copy link
Contributor

Signed-off-by: youjiali1995 zlwgx1023@gmail.com

What problem does this PR solve?

Issue Number: close ##25412
Problem Summary:

Batch-get assumes batchKeys is in order which is wrong.

What is changed and how it works?

Proposal: xxx

What's Changed:

Make keys in order.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • No code

Side effects

Release note

  • No release note.

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 15, 2021
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 15, 2021
Copy link
Contributor

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lysu
  • sticnarf

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 15, 2021
@youjiali1995
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: ae5c29a

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 15, 2021
@youjiali1995
Copy link
Contributor Author

/run-check_dev_2

@youjiali1995
Copy link
Contributor Author

[2021-06-15T06:58:10.801Z] ----------------------------------------------------------------------
[2021-06-15T06:58:10.801Z] FAIL: analyze_test.go:55: testSuite1.TestAnalyzePartition
[2021-06-15T06:58:10.801Z] 
[2021-06-15T06:58:10.801Z] analyze_test.go:57:
[2021-06-15T06:58:10.801Z]     testkit.WithPruneMode(tk, variable.Static, func() {
[2021-06-15T06:58:10.801Z]         tk.MustExec("use test")
[2021-06-15T06:58:10.801Z]         tk.MustExec("drop table if exists t")
[2021-06-15T06:58:10.801Z]         tk.MustExec("set @@tidb_analyze_version=2")
[2021-06-15T06:58:10.801Z]         createTable := `CREATE TABLE t (a int, b int, c varchar(10), primary key(a), index idx(b))
[2021-06-15T06:58:10.801Z]     PARTITION BY RANGE ( a ) (
[2021-06-15T06:58:10.802Z]     		PARTITION p0 VALUES LESS THAN (6),
[2021-06-15T06:58:10.802Z]     		PARTITION p1 VALUES LESS THAN (11),
[2021-06-15T06:58:10.802Z]     		PARTITION p2 VALUES LESS THAN (16),
[2021-06-15T06:58:10.802Z]     		PARTITION p3 VALUES LESS THAN (21)
[2021-06-15T06:58:10.802Z]     )`
[2021-06-15T06:58:10.802Z]         tk.MustExec(createTable)
[2021-06-15T06:58:10.802Z]         for i := 1; i < 21; i++ {
[2021-06-15T06:58:10.802Z]             tk.MustExec(fmt.Sprintf(`insert into t values (%d, %d, "hello")`, i, i))
[2021-06-15T06:58:10.802Z]         }
[2021-06-15T06:58:10.802Z]         tk.MustExec("analyze table t")
[2021-06-15T06:58:10.802Z] 
[2021-06-15T06:58:10.802Z]         is := tk.Se.(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema)
[2021-06-15T06:58:10.802Z]         table, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("t"))
[2021-06-15T06:58:10.802Z]         c.Assert(err, IsNil)
[2021-06-15T06:58:10.802Z]         pi := table.Meta().GetPartitionInfo()
[2021-06-15T06:58:10.802Z]         c.Assert(pi, NotNil)
[2021-06-15T06:58:10.802Z]         do, err := session.GetDomain(s.store)
[2021-06-15T06:58:10.802Z]         c.Assert(err, IsNil)
[2021-06-15T06:58:10.802Z]         handle := do.StatsHandle()
[2021-06-15T06:58:10.802Z]         for _, def := range pi.Definitions {
[2021-06-15T06:58:10.802Z]             statsTbl := handle.GetPartitionStats(table.Meta(), def.ID)
[2021-06-15T06:58:10.802Z]             c.Assert(statsTbl.Pseudo, IsFalse)
[2021-06-15T06:58:10.802Z]             c.Assert(len(statsTbl.Columns), Equals, 3)
[2021-06-15T06:58:10.802Z]             c.Assert(len(statsTbl.Indices), Equals, 1)
[2021-06-15T06:58:10.802Z]             for _, col := range statsTbl.Columns {
[2021-06-15T06:58:10.802Z]                 c.Assert(col.Len()+col.Num(), Greater, 0)
[2021-06-15T06:58:10.802Z]             }
[2021-06-15T06:58:10.802Z]             for _, idx := range statsTbl.Indices {
[2021-06-15T06:58:10.802Z]                 c.Assert(idx.Len()+idx.Num(), Greater, 0)
[2021-06-15T06:58:10.802Z]             }
[2021-06-15T06:58:10.802Z]         }
[2021-06-15T06:58:10.802Z] 
[2021-06-15T06:58:10.802Z]         tk.MustExec("drop table t")
[2021-06-15T06:58:10.802Z]         tk.MustExec(createTable)
[2021-06-15T06:58:10.802Z]         for i := 1; i < 21; i++ {
[2021-06-15T06:58:10.802Z]             tk.MustExec(fmt.Sprintf(`insert into t values (%d, %d, "hello")`, i, i))
[2021-06-15T06:58:10.802Z]         }
[2021-06-15T06:58:10.802Z]         tk.MustExec("alter table t analyze partition p0")
[2021-06-15T06:58:10.802Z]         is = tk.Se.(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema)
[2021-06-15T06:58:10.802Z]         table, err = is.TableByName(model.NewCIStr("test"), model.NewCIStr("t"))
[2021-06-15T06:58:10.802Z]         c.Assert(err, IsNil)
[2021-06-15T06:58:10.802Z]         pi = table.Meta().GetPartitionInfo()
[2021-06-15T06:58:10.802Z]         c.Assert(pi, NotNil)
[2021-06-15T06:58:10.802Z] 
[2021-06-15T06:58:10.802Z]         for i, def := range pi.Definitions {
[2021-06-15T06:58:10.802Z]             statsTbl := handle.GetPartitionStats(table.Meta(), def.ID)
[2021-06-15T06:58:10.802Z]             if i == 0 {
[2021-06-15T06:58:10.802Z]                 c.Assert(statsTbl.Pseudo, IsFalse)
[2021-06-15T06:58:10.802Z]                 c.Assert(len(statsTbl.Columns), Equals, 3)
[2021-06-15T06:58:10.802Z]                 c.Assert(len(statsTbl.Indices), Equals, 1)
[2021-06-15T06:58:10.802Z]             } else {
[2021-06-15T06:58:10.802Z]                 c.Assert(statsTbl.Pseudo, IsTrue)
[2021-06-15T06:58:10.802Z]             }
[2021-06-15T06:58:10.802Z]         }
[2021-06-15T06:58:10.802Z]     })
[2021-06-15T06:58:10.802Z] /home/jenkins/agent/workspace/tidb_ghpr_check_2/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:217:
[2021-06-15T06:58:10.802Z]     tk.c.Assert(err, check.IsNil, check.Commentf("sql:%s, %v, error stack %v", sql, args, errors.ErrorStack(err)))
[2021-06-15T06:58:10.802Z] ... value *errors.fundamental = analyze worker panic ("analyze worker panic")
[2021-06-15T06:58:10.802Z] ... sql:alter table t analyze partition p0, [], error stack analyze worker panic
[2021-06-15T06:58:10.802Z] github.com/pingcap/tidb/executor.init
[2021-06-15T06:58:10.802Z] 	/home/jenkins/agent/workspace/tidb_ghpr_check_2/go/src/github.com/pingcap/tidb/executor/analyze.go:247
[2021-06-15T06:58:10.802Z] runtime.doInit
[2021-06-15T06:58:10.802Z] 	/usr/local/go/src/runtime/proc.go:6309
[2021-06-15T06:58:10.802Z] runtime.doInit
[2021-06-15T06:58:10.802Z] 	/usr/local/go/src/runtime/proc.go:6286
[2021-06-15T06:58:10.802Z] runtime.main
[2021-06-15T06:58:10.802Z] 	/usr/local/go/src/runtime/proc.go:208
[2021-06-15T06:58:10.802Z] runtime.goexit
[2021-06-15T06:58:10.802Z] 	/usr/local/go/src/runtime/asm_amd64.s:1371

@youjiali1995
Copy link
Contributor Author

/run-integration-common-test

@ti-chi-bot ti-chi-bot merged commit f7f1878 into pingcap:master Jun 15, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.1 in PR #25417

youjiali1995 added a commit to ti-srebot/tidb that referenced this pull request Jun 15, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
youjiali1995 added a commit to youjiali1995/tidb that referenced this pull request Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.1 sig/transaction SIG:Transaction size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants