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

ddl: check delete range for some DDLs #33392

Merged
merged 8 commits into from
Apr 1, 2022

Conversation

wjhuang2016
Copy link
Member

@wjhuang2016 wjhuang2016 commented Mar 24, 2022

Signed-off-by: wjhuang2016 huangwenjun1997@gmail.com

What problem does this PR solve?

Issue Number: ref #33078

Problem Summary:
Try to add some checks for DDL

What is changed and how it works?

Check delete range for some DDLs.

Check List

A bug was found by this PR: #33620

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 24, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • hawkingrei
  • zimulala

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 release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 24, 2022
@wjhuang2016
Copy link
Member Author

/run-unit-test

4 similar comments
@wjhuang2016
Copy link
Member Author

/run-unit-test

@wjhuang2016
Copy link
Member Author

/run-unit-test

@wjhuang2016
Copy link
Member Author

/run-unit-test

@wjhuang2016
Copy link
Member Author

/run-unit-test

@sre-bot
Copy link
Contributor

sre-bot commented Mar 28, 2022

@wjhuang2016
Copy link
Member Author

/run-unit-test

1 similar comment
@wjhuang2016
Copy link
Member Author

/run-unit-test

@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 29, 2022
@wjhuang2016
Copy link
Member Author

/run-unit-test

1 similar comment
@wjhuang2016
Copy link
Member Author

/run-unit-test

@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 30, 2022
@wjhuang2016 wjhuang2016 force-pushed the check_del_range branch 2 times, most recently from a257a55 to b865315 Compare March 30, 2022 09:26
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 30, 2022
@wjhuang2016
Copy link
Member Author

/run-unit-test

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@@ -566,6 +566,9 @@ func TestSetPlacementRuleWithGCWorker(t *testing.T) {
// Make SetPdLoop take effects.
time.Sleep(time.Second)

fCancel := TempDisableEmulatorGC()
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to add this to fix this test, the adding check makes it unstable.

"github.com/pingcap/tidb/util/sqlexec"
)

func checkRangeCntByTableIDs(physicalTableIDs []int64, cnt int64) {
Copy link
Member

Choose a reason for hiding this comment

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

if it is released in the production environment. panic info will be too simple for DBA to judge the error.

BTW, if it is just in our test environment, we can make a build tag to skip this check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we put this file code to ddl_test.go?Or change the file name to test specifically. Because it's only used for testing.

Copy link
Member Author

Choose a reason for hiding this comment

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

// checkHistoryJobInTest does some sanity check to make sure something is correct after DDL complete.
// It's only check during the test environment, so it would panic directly.
// These checks may be controlled by configuration in the future.

It' could be enabled in our integration test environment, even in the production environment.
For now, it is just enabled in unit test environment, so I let it panic directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

When will the production environment be used?

break
}
fallthrough
case model.ActionDropSchema, model.ActionDropTable, model.ActionTruncateTable, model.ActionDropIndex, model.ActionDropPrimaryKey,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add a function to identify tasks of this type?Because there are a few places to use, in case of missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't have a good idea, any suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we add a function like IsRollbackDone?

select count(1) cnt from mysql.gc_delete_range_done where job_id = %?) as gdr;`
rs, err := s.ExecuteInternal(context.TODO(), query, job.ID, job.ID)
if err != nil {
if strings.Contains(err.Error(), "Not Supported") {
Copy link
Contributor

Choose a reason for hiding this comment

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

When we will go to this logic?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mock session

ddl/sanity_check.go Outdated Show resolved Hide resolved
"github.com/pingcap/tidb/util/sqlexec"
)

func checkRangeCntByTableIDs(physicalTableIDs []int64, cnt int64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we put this file code to ddl_test.go?Or change the file name to test specifically. Because it's only used for testing.

ddl/sanity_check.go Outdated Show resolved Hide resolved
ddl/sanity_check.go Outdated Show resolved Hide resolved
@zimulala
Copy link
Contributor

zimulala commented Apr 1, 2022

Excuse me, I saw in this PR description that you chose Unit Test, but there is no test code in this PR.

@wjhuang2016
Copy link
Member Author

Excuse me, I saw in this PR description that you chose Unit Test, but there is no test code in this PR.

TestSetPlacementRuleWithGCWorker is modified.

wjhuang2016 and others added 4 commits April 1, 2022 16:34
Co-authored-by: Lynn <zimu_xia@126.com>
Co-authored-by: Lynn <zimu_xia@126.com>
Co-authored-by: Lynn <zimu_xia@126.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Copy link
Contributor

@zimulala zimulala 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 ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 1, 2022
@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 Apr 1, 2022
@hawkingrei
Copy link
Member

/run-check_dev_2

@wjhuang2016
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: d8251d7

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 1, 2022
@ti-chi-bot
Copy link
Member

@wjhuang2016: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

metrics.DDLWorkerHistogram.WithLabelValues(metrics.WorkerFinishDDLJob, job.Type.String(), metrics.RetLabel(err)).Observe(time.Since(startTime).Seconds())
}()

func jobNeedGC(job *model.Job) bool {
Copy link
Member

Choose a reason for hiding this comment

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

It may be migrated into parser/model. it is easy for others to reuse.

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be moved when other packages need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 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