-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
/run-unit-test |
4 similar comments
/run-unit-test |
/run-unit-test |
/run-unit-test |
/run-unit-test |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/a00031325dc93b4f7bffd25792aebf839048aeeb |
/run-unit-test |
1 similar comment
/run-unit-test |
/run-unit-test |
1 similar comment
/run-unit-test |
a257a55
to
b865315
Compare
/run-unit-test |
5bb3a1f
to
bcb4e89
Compare
@@ -566,6 +566,9 @@ func TestSetPlacementRuleWithGCWorker(t *testing.T) { | |||
// Make SetPdLoop take effects. | |||
time.Sleep(time.Second) | |||
|
|||
fCancel := TempDisableEmulatorGC() |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
ddl/sanity_check.go
Outdated
break | ||
} | ||
fallthrough | ||
case model.ActionDropSchema, model.ActionDropTable, model.ActionTruncateTable, model.ActionDropIndex, model.ActionDropPrimaryKey, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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") { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mock session
"github.com/pingcap/tidb/util/sqlexec" | ||
) | ||
|
||
func checkRangeCntByTableIDs(physicalTableIDs []int64, cnt int64) { |
There was a problem hiding this comment.
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.
Excuse me, I saw in this PR description that you chose |
TestSetPlacementRuleWithGCWorker is modified. |
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-check_dev_2 |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: d8251d7
|
@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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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
Side effects
Documentation
Release note