-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
sysvar: Do not allow set tidb_auto_analyze_ratio to 0 #52190
Conversation
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔢 Self-check (PR reviewed by myself and ready for feedback.)
/retest |
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #52190 +/- ##
================================================
- Coverage 69.2555% 69.0307% -0.2248%
================================================
Files 1490 1490
Lines 420134 436249 +16115
================================================
+ Hits 290966 301146 +10180
- Misses 109658 114905 +5247
- Partials 19510 20198 +688
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #52190 +/- ##
================================================
+ Coverage 69.2555% 72.7679% +3.5124%
================================================
Files 1490 1490
Lines 420134 440180 +20046
================================================
+ Hits 290966 320310 +29344
+ Misses 109658 99685 -9973
- Partials 19510 20185 +675
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔢 Self-check (PR reviewed by myself and ready for feedback.)
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Test locally:
tiup cluster deploy upstream v7.5.0 upstream.yaml -p
tiup cluster start upstream
MySQL [(none)]> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.5.0
Edition: Community
Git Commit Hash: 069631e2ecfedc000ffb92c67207bea81380f020
Git Branch: heads/refs/tags/v7.5.0
UTC Build Time: 2023-11-24 08:50:14
GoVersion: go1.21.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> set global tidb_auto_analyze_ratio=0;
Query OK, 0 rows affected (0.02 sec)
MySQL [(none)]> select @@tidb_auto_analyze_ratio;
+---------------------------+
| @@tidb_auto_analyze_ratio |
+---------------------------+
| 0 |
+---------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> exit
MySQL [(none)]> select tidb_version();
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.0.0-alpha-664-gb2bd0b4fbf
Edition: Community
Git Commit Hash: b2bd0b4fbfda97e7f0a698baffc9c1269a84fb6c
Git Branch: rustin-patch-0
UTC Build Time: 2024-03-28 09:04:11
GoVersion: go1.21.1
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> select @@tidb_auto_analyze_ratio;
+---------------------------+
| @@tidb_auto_analyze_ratio |
+---------------------------+
| 0 |
+---------------------------+
1 row in set (0.00 sec)
MySQL [(none)]> set global tidb_auto_analyze_ratio=0;
ERROR 1105 (HY000): the value of tidb_auto_analyze_ratio should be greater than or equal to 0.000010
MySQL [(none)]> |
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
@@ -54,8 +54,10 @@ func TestSkipAnalyzeTableWhenAutoAnalyzeRatioIsZero(t *testing.T) { | |||
) | |||
tk.MustExec("insert into t1 values (1, 1), (2, 2), (3, 3)") | |||
tk.MustExec("insert into t2 values (1, 1), (2, 2), (3, 3)") | |||
// Set the auto analyze ratio to 0. | |||
tk.MustExec("set global tidb_auto_analyze_ratio = 0") | |||
// HACK: Set the auto analyze ratio to 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't change the old behavior.
/unhold |
[LGTM Timeline notifier]Timeline:
|
@songrijie: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this: 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. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: easonn7, qw4990, songrijie, time-and-fate The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: close #51582
Problem Summary:
Currently, if you set tidb_auto_analyze_ratio to 0, we will disable auto-analysis based on row changes, but we will still process the newly added indexes and tables.
This behavior is difficult to understand. I suppose most users will think 0 means we always need to analyze the table, no matter how many rows have been updated.
The historic reason we introduced it is that before #34643 this PR, there was no way to disable the auto-analyze feature without restarting the server. So we chose this special value to allow users to disable the auto-analysis feature. But now enable_tidb_auto_analyze is a global session variable. So we don't depend on this value.
What changed and how does it work?
Added verification for tidb_auto_analyze_ratio to make sure it cannot be zero and the minimum value is 0.00001.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.