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: dynamic adjust add index worker number. #8295

Merged
merged 28 commits into from
Dec 24, 2018

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Nov 13, 2018

What problem does this PR solve?

Currently, if tidb is doing a add index ddl job, then the client change the tidb_ddl_reorg_worker_cnt want to speed up add index, but this change will take effect next add index, won't affect current add index job.

What is changed and how it works?

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes


This change is Reviewable

@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520
Copy link
Contributor Author

@winkyao @zimulala @ciscoxll PTAL

@crazycs520 crazycs520 changed the title ddl: dynamic adjust add index worker number init ddl: dynamic adjust add index worker number. Nov 19, 2018
@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520
Copy link
Contributor Author

/run-integration-ddl-test

1 similar comment
@crazycs520
Copy link
Contributor Author

/run-integration-ddl-test

@winkyao
Copy link
Contributor

winkyao commented Nov 20, 2018

@crazycs520 Please find out why integration-ddl-test failed, https://github.com/pingcap/tidb-test/tree/master/ddl_test

ddl/db_test.go Outdated
}
if startReorganization {
workerCnt := rand.Intn(8) + 8
s.mustExec(c, fmt.Sprintf("set @@tidb_ddl_reorg_worker_cnt=%d", workerCnt))
Copy link
Contributor

Choose a reason for hiding this comment

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

How can we ensure the worker count is changed to workerCnt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

em... I check the log when do manual test to know the worker count is changed... 😂

ddl/index.go Show resolved Hide resolved
ddl/index.go Show resolved Hide resolved
Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

main changes LGTM

ddl/index.go Outdated
}

reorgInfo.d.mu.Lock()
reorgInfo.d.mu.hook.OnIndexWorkerReorgBefore(len(idxWorkers), len(kvRanges))
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 use gofail instead of this logic?

ddl/db_test.go Outdated
@@ -630,8 +680,16 @@ LOOP:
s.mustExec(c, sql)
}
num += step
case <-ticker2.C:
if changeWorkerNumEnable {
Copy link
Contributor

Choose a reason for hiding this comment

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

It will have data race.

@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520
Copy link
Contributor Author

/run-all-tests

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

ddl/db_test.go Outdated
s.tk.MustExec("drop table test_add_index")
}

func (s *testDBSuite) TestAddIndexWorkerNum(c *C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please put it to failtest/fail_db_test.go

@crazycs520
Copy link
Contributor Author

/run-all-tests

1 similar comment
@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520
Copy link
Contributor Author

/run-all-tests

ddl/testutil/testutil.go Show resolved Hide resolved

// gofail: var checkIndexWorkerNum bool
//if checkIndexWorkerNum {
// num := int(atomic.LoadInt32(&TestCheckWorkerNumber))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we don't need atomic.LoadInt3.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use to avoid data race.

ddl/index.go Outdated Show resolved Hide resolved
@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520 crazycs520 merged commit d20bf28 into pingcap:master Dec 24, 2018
@crazycs520 crazycs520 deleted the adjust-add-index-worker branch December 24, 2018 03:00
crazycs520 added a commit to crazycs520/tidb that referenced this pull request Dec 24, 2018
yu34po pushed a commit to yu34po/tidb that referenced this pull request Jan 2, 2019
@you06 you06 added the sig/sql-infra SIG: SQL Infra label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants