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

executor: migrate TestBatchInsertWithOnDuplicate to testify #26712

Merged
merged 17 commits into from
Aug 4, 2021

Conversation

tisonkun
Copy link
Contributor

@tisonkun tisonkun commented Jul 28, 2021

What problem does this PR solve?

Issue Number: close #26160

See also commits, I already separated into three commits.

Release note

None

Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jul 28, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • ichn-hu
  • xhebox

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 28, 2021
@github-actions github-actions bot added the sig/execution SIG execution label Jul 28, 2021
Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
Copy link
Contributor Author

/cc @mmyj

@ti-chi-bot
Copy link
Member

@tisonkun: GitHub didn't allow me to request PR reviews from the following users: mmyj.

Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @mmyj

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.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 30, 2021
@tisonkun tisonkun requested a review from ichn-hu August 2, 2021 13:17
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"),
}
goleak.VerifyTestMain(m, opts...)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to ignore these functions? how do we determine which function to ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see also https://internals.tidb.io/t/topic/280/2 They are already ignored by testleak and when we migrate to goleak, we repeat it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully we later fix all unreasonable leak, but we don't force it in this PR IMO.

Copy link
Contributor Author

@tisonkun tisonkun Aug 3, 2021

Choose a reason for hiding this comment

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

Because all the scope consists of other tests expect TestBatchInsertWithOnDuplicate, and actually, TestBatchInsertWithOnDuplicate doesn't suffer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, thanks for the explanation.

@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 Aug 3, 2021
@mmyj
Copy link
Member

mmyj commented Aug 3, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 602d8dc

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

@tiancaiamao tiancaiamao left a comment

Choose a reason for hiding this comment

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

I guess the leak is caused by other cases.
If you run

go test TestBatchInsertWithOnDuplicate

There is no leak from our repo.

executor/main_test.go Outdated Show resolved Hide resolved
executor/main_test.go Outdated Show resolved Hide resolved
executor/main_test.go Outdated Show resolved Hide resolved
@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

I guess the leak is caused by other cases.
If you run

go test TestBatchInsertWithOnDuplicate

There is no leak from our repo.

@tiancaiamao Yes it is not caused by TestBatchInsertWithOnDuplicate. As you can see TestMain actually handle the whole package. I think it is other tests to be blamed. You may be right that it is because store not close, etc. But we don't have to resolve in this PR since they are already ignored. We can gradually fix them on the fly refactoring IMO.

@xhebox
Copy link
Contributor

xhebox commented Aug 4, 2021

@xhebox if it is good to go, please help on tag as can-merge.

Not a committer, and I will wait for the opionion from tiancaiamao.

@tiancaiamao
Copy link
Contributor

I'm testing this branch, using binary search to locate the leak case.

go test -run [A-N] success
go test -run [N-Z] fail ...

Maybe when it fails when including the TestT ... let me have a try

@tiancaiamao
Copy link
Contributor

go test -run TestT -check.f Test[N-T] leak
go test -run TestT -check.f Test[N-Q] leak
go test -run TestT -check.f Test[N-O] no leak
go test -run TestT -check.f TestO no leak
go test -run TestT -check.f TestP leak

./memory_test.go:func (s *testMemoryLeak) TestPBMemoryLeak(c *C) {
./parallel_apply_test.go:func (s *testSuite) TestParallelApply(c *C) {
./executor_test.go:func (s *testSuiteP1) TestPessimisticSelectForUpdate(c *C) {
./executor_test.go:func (s *testSerialSuite) TestPointGetRepeatableRead(c *C) {
./executor_test.go:func (s *testSuiteP2) TestPointGetPreparedPlan(c *C) {
./executor_test.go:func (s *testSuiteP2) TestPointGetPreparedPlanWithCommitMode(c *C) {
./executor_test.go:func (s *testSuiteP2) TestPointUpdatePreparedPlan(c *C) {
./executor_test.go:func (s *testSuiteP2) TestPointUpdatePreparedPlanWithCommitMode(c *C) {
./executor_test.go:func (s *testSuite1) TestPartitionHashCode(c *C) {
./executor_test.go:func (s *testSuiteP1) TestPrepareLoadData(c *C) {
./executor_test.go:func (s *testSerialSuite) TestPrevStmtDesensitization(c *C) {
./executor_test.go:func (s *testSuiteP2) TestProjectionBitType(c *C) {
./seqtest/seq_executor_test.go:func (s *seqTestSuite) TestParallelHashAggClose(c *C) {
./seqtest/seq_executor_test.go:func (s *seqTestSuite) TestPrepareMaxParamCountCheck(c *C) {
./seqtest/seq_executor_test.go:func (s *seqTestSuite) TestPessimisticConflictRetryAutoID(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPrepared(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedLimitOffset(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedNullParam(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPrepareWithAggregation(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedIssue7579(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedInsert(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedUpdate(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedDelete(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPrepareDealloc(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedIssue8153(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedIssue8644(c *C) {
./seqtest/prepared_test.go:func (s *seqTestSuite) TestPreparedIssue17419(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionIndexJoin(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionUnionScanIndexJoin(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPointGetwithRangeAndListPartitionTable(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionReaderUnderApply(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionInfoDisable(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionTableWithDifferentJoin(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestParallelApply(c *C) {
./update_test.go:func (s *testSuite11) TestPessimisticUpdatePKLazyCheck(c *C) {
./batch_point_get_test.go:func (s *testBatchPointGetSuite) TestPointGetForTemporaryTable(c *C) {
./shuffle_test.go:func (s *testPartitionSuite) TestPartitionRangeSplitter(c *C) {
./infoschema_reader_test.go:func (s *testInfoschemaTableSuite) TestProfiling(c *C) {
./infoschema_reader_test.go:func (s *testInfoschemaTableSerialSuite) TestPartitionsTable(c *C) {
./prepared_test.go:func (s *testSuite1) TestPreparedNameResolver(c *C) {
./prepared_test.go:func (s *testSuite1) TestPreparedDDL(c *C) {
./prepared_test.go:func (s *testSerialSuite) TestPrepareStmtAfterIsolationReadChange(c *C) {
./prepared_test.go:func (s *testSuite12) TestPreparedStmtWithHint(c *C) {
./prepared_test.go:func (s *testSerialSuite) TestPlanCacheClusterIndex(c *C) {
./prepared_test.go:func (s *testPrepareSuite) TestPlanCacheWithDifferentVariableTypes(c *C) {
./window_test.go:func (s *testSuite7) TestPipelinedWindowFunctions(c *C) {
./window_test.go:func (s *testSuite7) TestPipelinedWindowParallelFunctions(c *C) {
./window_test.go:func (s *testSuite7) TestPipelinedSlidingWindowFunctions(c *C) {
./tiflash_test.go:func (s *tiflashTestSuite) TestPartitionTable(c *C) {
./index_lookup_join_test.go:func (s *testSuite5) TestPartitionTableIndexJoinAndIndexReader(c *C) {
./distsql_test.go:func (s *testSuite3) TestPushLimitDownIndexLookUpReader(c *C) {
./distsql_test.go:func (s *testSuite3) TestPartitionTableIndexLookUpReader(c *C) {
./distsql_test.go:func (s *testSuite3) TestPartitionTableRandomlyIndexLookUpReader(c *C) {
./distsql_test.go:func (s *testSuite3) TestPartitionTableIndexJoinIndexLookUp(c *C) {
./explainfor_test.go:func (s *testPrepareSerialSuite) TestPointGetUserVarPlanCache(c *C) {
./slow_query_test.go:func (s *testExecSerialSuite) TestParseSlowLogPanic(c *C) {
./slow_query_test.go:func (s *testExecSuite) TestParseSlowLogFile(c *C) {
./slow_query_test.go:func (s *testExecSerialSuite) TestParseSlowLogFileSerial(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGet(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetOverflow(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetDataTooLong(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetCharPK(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetAliasTableCharPK(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetVarcharPK(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetBinaryPK(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetAliasTableBinaryPK(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetByRowID(c *C) {
./point_get_test.go:func (s *testSerialSuite) TestPartitionMemCacheReadLock(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetWriteLock(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetLockExistKey(c *C) {
./point_get_test.go:func (s *testPointGetSuite) TestPointGetIssue25167(c *C) {
./index_merge_reader_test.go:func (s *testSuite1) TestPartitionTableRandomIndexMerge(c *C) {
./aggregate_test.go:func (s *testSuiteAgg) TestPR15242ShallowCopy(c *C) {
./aggregate_test.go:func (s *testSuiteAgg) TestParallelStreamAggGroupConcat(c *C) {
./write_test.go:func (s *testSuite4) TestPartitionedTableReplace(c *C) {
./write_test.go:func (s *testSuite4) TestPartitionedTableUpdate(c *C) {
./write_test.go:func (s *testSuite4) TestPartitionedTableDelete(c *C) {
./write_test.go:func (s *testSuite7) TestPessimisticDeleteYourWrites(c *C) {
./aggfuncs/func_percentile_test.go:func (s *testSuite) TestPercentile(c *C) {
./executor_required_rows_test.go:func (s *testExecSuite) TestProjectionUnparallelRequiredRows(c *C) {
./executor_required_rows_test.go:func (s *testExecSuite) TestProjectionParallelRequiredRows(c *C) {
./insert_test.go:func (s *testSuite10) TestPaddingCommonHandle(c *C) {
./insert_test.go:func (s *testSuite3) TestPartitionInsertOnDuplicate(c *C) {

@tiancaiamao
Copy link
Contributor

go test -run TestT -check.f TestP[a-n] leak
go test -run TestT -check.f TestP[a-g] leak
go test -run TestT -check.f TestP[a-e] leak
go test -run TestT -check.f TestPa leak
go test -run TestT -check.f TestPartition leak

./executor_test.go:func (s *testSuite1) TestPartitionHashCode(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionIndexJoin(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionUnionScanIndexJoin(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionReaderUnderApply(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionInfoDisable(c *C) {
./partition_table_test.go:func (s *partitionTableSuite) TestPartitionTableWithDifferentJoin(c *C) {
./shuffle_test.go:func (s *testPartitionSuite) TestPartitionRangeSplitter(c *C) {
./infoschema_reader_test.go:func (s *testInfoschemaTableSerialSuite) TestPartitionsTable(c *C) {
./tiflash_test.go:func (s *tiflashTestSuite) TestPartitionTable(c *C) {
./index_lookup_join_test.go:func (s *testSuite5) TestPartitionTableIndexJoinAndIndexReader(c *C) {
./distsql_test.go:func (s *testSuite3) TestPartitionTableIndexLookUpReader(c *C) {
./distsql_test.go:func (s *testSuite3) TestPartitionTableRandomlyIndexLookUpReader(c *C) {
./distsql_test.go:func (s *testSuite3) TestPartitionTableIndexJoinIndexLookUp(c *C) {
./point_get_test.go:func (s *testSerialSuite) TestPartitionMemCacheReadLock(c *C) {
./index_merge_reader_test.go:func (s *testSuite1) TestPartitionTableRandomIndexMerge(c *C) {
./write_test.go:func (s *testSuite4) TestPartitionedTableReplace(c *C) {
./write_test.go:func (s *testSuite4) TestPartitionedTableUpdate(c *C) {
./write_test.go:func (s *testSuite4) TestPartitionedTableDelete(c *C) {
./insert_test.go:func (s *testSuite3) TestPartitionInsertOnDuplicate(c *C) {

go test -run TestT -check.f testSuite1.TestPart no leak
go test -run TestT -check.f partitionTableSuite.TestPart no leak
go test -run TestT -check.f testPartitionSuite.TestPart no leak
go test -run TestT -check.f testInfoschemaTableSerialSuite.TestPart no leak
go test -run TestT -check.f tiflashTestSuite.TestPart leak!!!!

This is the root cause @tisonkun

@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

@tiancaiamao thanks! I think we can comment this information on #26854 and fix them on the fly? Or you think it block this PR to merge?

@tiancaiamao
Copy link
Contributor

I've filed a PR to fix the leak I found #26881

IMO, add a whitelist of goleak.Option is not a good idea.
It's easy to add the whitelist, but very difficult to remove it.

So what's the purpose of the test case restructing? we want the code to be maintainable, the test case to be more stable ... this time it's a good chance for us to improve, but if we add the bad cases into the whitelist, nothing improved. We can't achieve anything we really wanted ...

@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

I've filed a PR to fix the leak I found #26881

IMO, add a whitelist of goleak.Option is not a good idea.
It's easy to add the whitelist, but very difficult to remove it.

So what's the purpose of the test case restructing? we want the code to be maintainable, the test case to be more stable ... this time it's a good chance for us to improve, but if we add the bad cases into the whitelist, nothing improved. We can't achieve anything we really wanted ...

Agree and thank you for the PR!

@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

@tiancaiamao actually I keep a same opinion with you as already posted on https://internals.tidb.io/t/topic/200/3?u=tison. My suggestion is unblocking this PR and later drop unreasonable leak ignores. You may think "later" be never and that's great you help on fixing it right now.

@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

Given #26881 merged, let me try to remove the whitelist.

@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

If you don't like whitelist, we can avoid using goleak.verifyMain here, create another issue to add it back the debug in that PR.

Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

@tiancaiamao I push two commits to narrow goleak validation in the migrated functions. PTAL

@tisonkun
Copy link
Contributor Author

tisonkun commented Aug 4, 2021

Ummm well goleak verify stack and we can hardly run it separatedly

Signed-off-by: tison <wander4096@gmail.com>
Comment on lines +32 to +34
session.SetSchemaLease(0)
session.DisableStats4Test()
d, err := session.BootstrapSession(store)
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a concern this will make our CI take a lot of time than before.
In the past, one test suite create one store/domain.
If after the refactor, each test case create one store/domain, the operation is heavier than before... session.BootstrapSession is not cheap.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can solve it later, through~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I'll think of reusing store/domain between tests. Maybe we come back to batch several tests in serial with testify suite.

@tiancaiamao
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: f70c4ae

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

@tisonkun: 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.

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. sig/execution SIG execution size/XXL Denotes a PR that changes 1000+ 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.

migrate test-infra to testify for executor/write_concurrent_test.go
6 participants