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

statistics: add tests for global-stats when add and delete a single partition #23256

Merged
merged 14 commits into from
Mar 12, 2021

Conversation

Reminiscent
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

  1. Add tests for global-stats when adding and deleting single partitions.
  2. fix the race test for TestCMSketchCodingTopN

What is changed and how it works?

  • The change in files statistics/cmsketch_test.go and statistics/statistics_test.go are used to avoid the race test.
  • Add tests for global-stats when we add or delete a partition.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Release note

  • No release note

@Reminiscent Reminiscent requested a review from a team as a code owner March 11, 2021 07:07
@Reminiscent Reminiscent requested review from lzmhhh123 and removed request for a team March 11, 2021 07:07
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 11, 2021
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 12, 2021
@@ -304,89 +303,3 @@ func (s *testStatisticsSuite) TestCMSketchCodingTopN(c *C) {
// do not panic
DecodeCMSketchAndTopN([]byte{}, rows)
}

func (s *testStatisticsSuite) TestMergeTopN(c *C) {
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 we change here to serial test. It will cause the import cycle.

@@ -2082,6 +2083,93 @@ func (s *testStatsSuite) TestFeedbackCounter(c *C) {
c.Assert(subtraction(newNum, oldNum), Equals, 20)
}

func (s *testSerialStatsSuite) TestMergeTopN(c *C) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just copy from the origin implementation.

@@ -318,9 +318,9 @@ func (h *Handle) MergePartitionStats2GlobalStats(sc sessionctx.Context, opts map
return
}
globalTableInfo := globalTable.Meta()
partitionNum := globalTableInfo.Partition.Num
Copy link
Contributor Author

@Reminiscent Reminiscent Mar 12, 2021

Choose a reason for hiding this comment

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

The globalTableInfo.Partition.Num do not record the added partitions. So we should use the len(globalTableInfo.Partition.Definitions) to replace it.

@Reminiscent Reminiscent requested a review from a team as a code owner March 12, 2021 05:59
@@ -506,7 +506,34 @@ func (s *testFastAnalyze) TestFastAnalyze(c *C) {
c.Assert(result.Rows()[1][5], Equals, "2")
c.Assert(result.Rows()[2][5], Equals, "3")
*/
}

func (s *testSerialSuite2) TestFastAnalyze4GlobalStats(c *C) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix the unstable test.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 12, 2021
// We did not analyze partition p1, so the value here has not changed
c.Assert(globalStats.Count, Equals, int64(7))

tk.MustExec("analyze table t;")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please only analyze p1 here since p0 and p2 are already up-to-date, and then check if the global.count is 9.

@github-actions github-actions bot added the sig/execution SIG execution label Mar 12, 2021
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • qw4990
  • rebelice

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 Mar 12, 2021
@qw4990
Copy link
Contributor

qw4990 commented Mar 12, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 666ee02

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

/run-tics-test

@Reminiscent
Copy link
Contributor Author

/run-all-tests

@qw4990 qw4990 merged commit 1e2f1c0 into pingcap:master Mar 12, 2021
@Reminiscent Reminiscent deleted the analyzePartition branch August 5, 2021 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics sig/execution SIG execution size/L Denotes a PR that changes 100-499 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.

4 participants