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

*: add support for disabling noop variables #35496

Merged
merged 8 commits into from
Jun 21, 2022

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Jun 19, 2022

What problem does this PR solve?

Issue Number: close #8895

Problem Summary:

TiDB features a set of "noop sysvars", which are imported from MySQL 5.6 and are used for compatibility with applications that expect certain system variables to be present. These sysvars do nothing: and without reading the source code, it's not possible to differentiate between a regular sysvar and a noop sysvar.

Noops violate the principal of least surprise, since when the system variables are present they are expected to do something. It requires exceptional expertise to have read all the docs or notice the feature does not work as intended. Often the database team won't have the application-level expertise to know if the application is working correctly, because they rely on errors being returned (of which there will be none).

Thus, adding support to disable noop variables makes safe migrations easier.

What is changed and how it works?

A new system variable tidb_enable_noop_variables is introduced. The default is ON, which is compatible with the existing behavior. When set to OFF, TiDB has the following behaviors:

  • Setting a noop sysvar returns a warning.
  • SHOW [GLOBAL] VARIABLES no longer displays noop sysvars.
  • SELECT @@noopvars returns a warning.

The warnings returned by setting and selecting a noop sysvar differ. The statement select * from information_schema.CLIENT_ERRORS_SUMMARY_GLOBAL; can be used to check if a TiDB server has been asked to get or set a noop system variable.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
mysql> SET GLOBAL tidb_enable_noop_variables=0;
Query OK, 0 rows affected (0.00 sec)

mysql> SET query_cache_type=2;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> select * from information_schema.CLIENT_ERRORS_SUMMARY_GLOBAL;
+--------------+--------------------------------------------------------------------------+-------------+---------------+---------------------+---------------------+
| ERROR_NUMBER | ERROR_MESSAGE                                                            | ERROR_COUNT | WARNING_COUNT | FIRST_SEEN          | LAST_SEEN           |
+--------------+--------------------------------------------------------------------------+-------------+---------------+---------------------+---------------------+
|         8144 | setting %s has no effect in TiDB                                         |           0 |             1 | 2022-06-19 13:23:21 | 2022-06-19 13:23:21 |
|         1193 | Unknown system variable '%-.64s'                                         |           2 |             2 | 2022-06-19 13:23:02 | 2022-06-19 13:23:10 |
|         1229 | Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL |           1 |             1 | 2022-06-19 13:23:07 | 2022-06-19 13:23:07 |
+--------------+--------------------------------------------------------------------------+-------------+---------------+---------------------+---------------------+
3 rows in set (0.00 sec)
  • 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

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

A new system variable `tidb_enable_noop_variables` is introduced. The default is `ON`, which is compatible with the existing behavior. When set to `OFF`, TiDB has the following behaviors:

* Setting a noop sysvar returns a warning.
* SHOW [GLOBAL] VARIABLES no longer displays noop sysvars.
* SELECT @@noopvars returns a warning.

The warnings returned by setting and selecting a noop sysvar differ. The statement `select * from information_schema.CLIENT_ERRORS_SUMMARY_GLOBAL;` can be used to check if a TiDB server has been asked to get or set a noop system variable.

@morgo morgo requested a review from a team as a code owner June 19, 2022 19:25
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jun 19, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • 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 Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 19, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jun 19, 2022

@morgo morgo requested a review from bb7133 June 19, 2022 19:58
Copy link
Contributor

@xhebox xhebox left a comment

Choose a reason for hiding this comment

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

Rest LGTM

errno/errname.go Show resolved Hide resolved
executor/set_test.go Show resolved Hide resolved
executor/show.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 20, 2022
@morgo
Copy link
Contributor Author

morgo commented Jun 20, 2022

/run-unit-test

Copy link
Member

@bb7133 bb7133 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 status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 21, 2022
@bb7133
Copy link
Member

bb7133 commented Jun 21, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 6a63dc9

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

/run-mysql-test
/run-unit-test

@hawkingrei
Copy link
Member

/run-mysql-test

1 similar comment
@hawkingrei
Copy link
Member

/run-mysql-test

@ti-chi-bot ti-chi-bot merged commit 5c9ad77 into pingcap:master Jun 21, 2022
@sre-bot
Copy link
Contributor

sre-bot commented Jun 21, 2022

TiDB MergeCI notify

🔴 Bad News! [1] CI still failing after this pr merged.
These failed integration tests don't seem to be introduced by the current PR.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/integration-common-test 🔴 failed 1, success 10, total 11 23 min Existing failure
idc-jenkins-ci/integration-cdc-test 🟢 all 34 tests passed 28 min Existing passed
idc-jenkins-ci-tidb/common-test 🟢 all 12 tests passed 10 min Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 8 min 33 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 8 min 5 sec Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 7 min 45 sec Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 5 min 41 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 3 min 13 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 2 min 43 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

@morgo morgo deleted the tidb-enable-noop-variables branch June 22, 2022 20:12
morgo added a commit to morgo/tidb that referenced this pull request Jun 28, 2022
* upstream/master:
  sessionctx: support encoding and decoding session variables (pingcap#35531)
  planner: add batch_point_get access object (pingcap#35230)
  sessionctx: set skipInit false for TiDBOptProjectionPushDown and TiDBOptAggPushDown (pingcap#35491)
  *: add support for disabling noop variables (pingcap#35496)
  lightning: add store write limiter (pingcap#35193)
  expression: avoid padding 0 when implicitly cast to binary (pingcap#35053)
  types: fix creating partition tables fail in ANSI_QUOTES mode (pingcap#35379)
  executor: add the missed runtime stats when the index merge partial task returns 0 row (pingcap#35297)
  statistics: batch insert topn and bucket when saving table stats (pingcap#35326)
  parser: Add support for INTERVAL expr unit + expr (pingcap#30253) (pingcap#35390)
  config: add missing nodelay example (pingcap#35255)
  *: Introduce `OptimisticTxnContextProvider` for optimistic txn (pingcap#35131)
  statistics: fix panic when using wrong globalStats.Indices key (pingcap#35424)
  *: fix store token is up to the limit in test (pingcap#35374)
  *: enable more flaky and update bazel config (pingcap#35500)
  ddl: expose getPrimaryKey() as a public method of model.TableInfo (pingcap#35512)
  expression, util: add `KeyWithoutTrimRightSpace` for collator (pingcap#35475)
  infoschema: try on each PD member until one succeeds or all fail (pingcap#35285)
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/M Denotes a PR that changes 30-99 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.

Support for tidb_enable_noop_sysvars
6 participants