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

config, sysvar: add config instance.enable_ddl and sysvar tidb_enable_ddl #35425

Merged
merged 37 commits into from
Aug 1, 2022

Conversation

CbcWestwolf
Copy link
Member

@CbcWestwolf CbcWestwolf commented Jun 16, 2022

What problem does this PR solve?

Issue Number: ref #34960

Problem Summary:

Before, if we want to disable DDL in a node/instance, we have to change the configuration and restart the node.

What is changed and how it works?

In this PR we introduce an instance scope variable enable_ddl and the corresponding config item instance.enable_ddl.

Check List

Tests

  • Unit test (using previous testing)
  • 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

Manual Test Steps

Test 1

  1. start a tiup playground with two TiDB instances (port 4000 and 4001): tiup playground --db 2 --db.binpath ~/tidb/bin/tidb-server
  2. start two sessions connecting to two instances separately
  3. using curl http://127.0.0.1:10081/info/all to check which instance is the owner (assume 4000)
  4. in the session, using set @@global.tidb_enable_ddl = 0/1 to disable/enable ddl. When disabling ddl in the "owner", another instance should be the owner by checking curl http://127.0.0.1:10081/info/all
  5. using curl -X POST http://127.0.0.1:10080/ddl/owner/resign to let the owner(4000) start a new campaign. the instance disabled ddl should not be an owner, and the instance enabled ddl could be an owner.

Test 2

  1. Start two TiDB servers, say tidb-a(DDL owner) and tidb-b.
  2. Execute on tidb-a: set @@global.tidb_enable_ddl = false;
  3. Stop tidb-b, or just send a resign signal to tidb-b
  4. Execute on tidb-a: set @@global.tidb_enable_ddl = true;
  5. Execute on tidb-a: create table t (a int);

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Previously, TiDB users use the config item `run-ddl` to control whether the TiDB cluster could run DDL.

From now on, users can use the config item `instance.tidb_enable_ddl` to control whether the TiDB instance could run DDL, and the instance system variable `tidb_enable_ddl` to change online.

@CbcWestwolf CbcWestwolf requested a review from a team as a code owner June 16, 2022 03:38
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jun 16, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • qw4990
  • tangenta

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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 16, 2022
@CbcWestwolf
Copy link
Member Author

/run-unit-test

@sre-bot
Copy link
Contributor

sre-bot commented Jun 16, 2022

@CbcWestwolf
Copy link
Member Author

/cc morgo bb7133 zimulala xiongjiwei

ddl/ddl.go Outdated
// Otherwise, we needn't do that.
if RunWorker {
if config.GetGlobalConfig().Instance.EnableDDL.Load() {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems we still can not disable the node to be owner after setting it to false, because the ddl started from here on the server initialized

Comment on lines 1781 to 1782
// EnableDDL indicates whether the tidb-server runs DDL statements,
EnableDDL = "enable_ddl"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we name it TiDBEnableDDL? For PluginDir: this variable is actually a MySQL compatible variable, but for EnableDDL, MySQL has no such notion of this.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 18, 2022
@ti-chi-bot ti-chi-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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 Jun 23, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 23, 2022
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 25, 2022
ddl/ddl.go Outdated

d.wg.Run(d.limitDDLJobs)
d.sessPool = newSessionPool(ctxPool, d.store)
d.workers = make(map[workerType]*worker, 2)
Copy link
Contributor

@xhebox xhebox Jun 28, 2022

Choose a reason for hiding this comment

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

Then you will still enable the runner. I suggest you to make *ddl having a real Start and Stop. Start() at L470 is more like an one-shot Run()/Begin().

@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 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 Aug 1, 2022
@CbcWestwolf
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@CbcWestwolf: /merge is only allowed for the committers, you can assign this pull request to the committer in list by filling /assign @committer in the comment to help merge this pull request.

In response to this:

/merge

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.

@tangenta
Copy link
Contributor

tangenta commented Aug 1, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: f47dd96

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

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: af356cc

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 1, 2022
@ti-chi-bot ti-chi-bot merged commit fc217d4 into pingcap:master Aug 1, 2022
@CbcWestwolf CbcWestwolf deleted the enable_ddl branch August 1, 2022 07:06
@sre-bot
Copy link
Contributor

sre-bot commented Aug 1, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [1] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-ddl-test ✅ all 6 tests passed 6 min 18 sec Fixed
idc-jenkins-ci/integration-cdc-test 🟢 all 36 tests passed 25 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 11 tests passed 21 min Existing passed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 17 tests passed 18 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 7 min 2 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 6 min 18 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 5 min 33 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 34 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 24 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

morgo pushed a commit to morgo/tidb that referenced this pull request Aug 1, 2022
morgo added a commit to morgo/tidb that referenced this pull request Aug 1, 2022
* upstream/master:
  ddl/schematracker: fix SetDDL will cause data race (pingcap#36768)
  planner: check virtual column for tiflash (pingcap#36771)
  *: replace defer clean with t.Cleanup (pingcap#36722)
  ddl: fix inaccurate row_count for `admin show ddl jobs` (pingcap#36716)
  config, sysvar: add config `instance.enable_ddl` and sysvar `tidb_enable_ddl` (pingcap#35425)
  *: enable part revive for all code (pingcap#36703)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

9 participants