tikv
tikv copied to clipboard
statistics: remove unreachable code
What is changed and how it works?
Removed some unreachable code. The code is now unreachable as TiDB no longer sends mixed analyze requests to TiKV if the statistics version is set to 2.
You can only find one reference of the mixed request type in TiDB.
You can find it here: https://github.com/pingcap/tidb/blob/12b37d88dceb4eb4da6fe316fb4d0af2024ab58b/pkg/executor/builder.go#L2706
But for version 2, we use buildAnalyzeSamplingPushdown to build the analysis task.
Issue Number: Ref https://github.com/tikv/tikv/issues/16463
What's Changed:
Related changes
- [ ] PR to update
pingcap/docs/pingcap/docs-cn: - [ ] Need to cherry-pick to the release branch
Check List
Tests
- [ ] Unit test
- [x] Integration test
- [x] 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
Release note
None
[REVIEW NOTIFICATION]
This pull request has been approved by:
- Connor1996
- JmPotato
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.
Test locally:
- Start the tidb cluster with patch:
tiup playground nightly --kv.binpath /Volumes/t7/code/tikv/target/aarch64-apple-darwin/debug/tikv-server
mysql> select * from information_schema.cluster_info;
+---------+-----------------+-----------------+---------------------------+------------------------------------------+---------------------+--------------+-----------+
| TYPE | INSTANCE | STATUS_ADDRESS | VERSION | GIT_HASH | START_TIME | UPTIME | SERVER_ID |
+---------+-----------------+-----------------+---------------------------+------------------------------------------+---------------------+--------------+-----------+
| tidb | 127.0.0.1:4000 | 127.0.0.1:10080 | 8.2.0-alpha-3-g79c1499bec | 79c1499bec7e609a051634c87460511b203c5389 | 2024-05-11 15:01:48 | 9m0.4416s | 713 |
| pd | 127.0.0.1:2379 | 127.0.0.1:2379 | 8.2.0-alpha-1-g4a7bffcb3 | 4a7bffcb3baf7a8e2515e70834d8567bc17439da | 2024-05-11 15:01:18 | 9m30.441602s | 0 |
| tiflash | 127.0.0.1:3930 | 127.0.0.1:20292 | 8.2.0-alpha-17-g8e50de84e | 8e50de84e6d6ecdcc108990217b70b6bb3f50271 | 2024-05-11 15:01:55 | 8m53.441603s | 0 |
| tikv | 127.0.0.1:20160 | 127.0.0.1:20180 | 8.2.0-alpha | 87c9a2a0965ae512fd254e26733ccc0c424bb36a | 2024-05-11 15:01:27 | 9m21.441603s | 0 |
+---------+-----------------+-----------------+---------------------------+------------------------------------------+---------------------+--------------+-----------+
4 rows in set (0.01 sec)
- Create a table and analyze with stats version 2:
create table t(a int);
import { Client } from "https://deno.land/x/mysql/mod.ts";
const client = await new Client().connect({
hostname: "127.0.0.1",
port: 4000,
username: "root",
db: "test",
password: "",
});
for (let i = 0; i < 2000; i++) {
await client.execute(`INSERT INTO t (a) VALUES (?)`, [i]);
if (i % 2 === 0) {
await client.execute(`INSERT INTO t (a) VALUES (?)`, [i]);
}
}
await client.close();;
analyze table t;
create table t1(a int);
import { Client } from "https://deno.land/x/mysql/mod.ts";
const client = await new Client().connect({
hostname: "127.0.0.1",
port: 4000,
username: "root",
db: "test",
password: "",
});
for (let i = 0; i < 2000; i++) {
await client.execute(`INSERT INTO t1 (a) VALUES (?)`, [i]);
if (i % 2 === 0) {
await client.execute(`INSERT INTO t1 (a) VALUES (?)`, [i]);
}
}
await client.close();;
set @@session.tidb_analyze_version=1;
analyze table t1;
- Create a new table with a string index:
create table t2(a varchar(50), b int, PRIMARY KEY (a));
import { Client } from "https://deno.land/x/mysql/mod.ts";
const client = await new Client().connect({
hostname: "127.0.0.1",
port: 4000,
username: "root",
db: "test",
password: "",
});
for (let i = 0; i < 2000; i++) {
const a = `string${i}`;
const b = i;
await client.execute(`INSERT INTO t2 (a, b) VALUES (?, ?)`, [a, b]);
}
await client.close();
set @@session.tidb_analyze_version=1;
analyze table t2;
@time-and-fate: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.
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 ti-community-infra/tichi repository.
For the backward compatibility:
- This code has been unreachable since v5.1.0.
- For tidb v5.0.x, we didn't allow users to use the analysis version 2.
/merge
@overvenus: It seems you want to merge this PR, I will help you trigger all the tests:
/run-all-tests
You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.
If you have any questions about the PR merge process, please refer to pr process.
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.
This pull request has been accepted and is ready to merge.