*: add infoschema client errors (#22382)#23268
*: add infoschema client errors (#22382)#23268ti-srebot wants to merge 1 commit intopingcap:release-5.0-rcfrom
Conversation
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
|
[REVIEW NOTIFICATION] This pull request has not been approved. 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. DetailsReviewer can indicate their review by writing |
|
/run-all-tests |
|
@morgo please accept the invitation then you can push to the cherry-pick pull requests. |
|
This merged clean, it is just missing parser support for |
cherry-pick #22382 to release-5.0-rc
You can switch your code base to this Pull Request by using git-extras:
# In tidb repo: git pr https://github.com/pingcap/tidb/pull/23268After apply modifications, you can push your change to this PR via:
What problem does this PR solve?
Issue Number: close #14433
Revives PR: #20785
Problem Summary:
In the PR #22351 , it is proposed that multiStmt be permitted as a warning, and later changed to a default. This provides an upgrade path for users.
The problem is, errors sent to the client were previously not captured by the server. So it is difficult to tell if a user is depending on the buggy behavior of multiStmt, and if the defaults change will cause them problems.
Thus, the proposal is to cherry-pick to 4.0 and 5.0 to provide a viable way to get past the multiStmt vulnerability.
What is changed and how it works?
What's Changed:
This PR introduces a method to observe errors and warnings sent to clients. For example, using multiStmt as an example:
(The warning is the default, when set to
OFF, it generated an error).In total, three new information schema tables have been introduced:
The design is modeled loosely based on what MySQL 8.0 has in performance_schema. But there are the following differences to be aware of:
TRUNCATE TABLEcommand. But since these are in infoschema in TiDB, a commandFLUSH CLIENT_ERRORS_SUMMARYis added.errnopackage - some are known not to be generated. Also, it creates a very large table if there are a lot of users or hosts.ERROR_MESSAGE (in sprintf format), not theERROR_NAME. This is a current limitation based on what is stored in theerrno` package. I think it's fine.ERROR_RAISED/ERROR_HANDLEDcounts, and the columns are just renamed toERROR_COUNT. TiDB does not have stored procs, and thus no error handling.How it Works:
The errors and warnings could be generated anywhere in code. I capture them not at generate time, but as they are sent to the client. This means that internal sql execution that triggers warnings etc. is not logged.
There is no persistence of the statistics, and no cluster-wide view.
Related changes
Check List
Tests
Side effects
Release note