-
Notifications
You must be signed in to change notification settings - Fork 6.2k
workload-based learning: save the metrics and create new workload_values table #59126
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
Changes from all commits
3e6183e
f62038d
aab0e89
6027754
bf1ccd2
5c7d97d
650d81c
3421027
a924d0b
a012596
84d0688
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -345,7 +345,7 @@ func TestProcessChunkWith(t *testing.T) { | |
| require.NoError(t, err) | ||
| checksumMap := checksum.GetInnerChecksums() | ||
| require.Len(t, checksumMap, 1) | ||
| require.Equal(t, verify.MakeKVChecksum(111, 3, 14585065391351463171), *checksumMap[verify.DataKVGroupID]) | ||
| require.Equal(t, verify.MakeKVChecksum(111, 3, 17951921359894607752), *checksumMap[verify.DataKVGroupID]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this is changed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as following |
||
| }) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1752,18 +1752,18 @@ func TestTiDBEncodeKey(t *testing.T) { | |
| err := tk.QueryToErr("select tidb_encode_record_key('test', 't1', 0);") | ||
| require.ErrorContains(t, err, "doesn't exist") | ||
| tk.MustQuery("select tidb_encode_record_key('test', 't', 1);"). | ||
| Check(testkit.Rows("74800000000000006e5f728000000000000001")) | ||
| Check(testkit.Rows("7480000000000000705f728000000000000001")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why EncodeKeyTest is changed.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I added a new system table. |
||
|
|
||
| tk.MustExec("alter table t add index i(b);") | ||
| err = tk.QueryToErr("select tidb_encode_index_key('test', 't', 'i1', 1);") | ||
| require.ErrorContains(t, err, "index not found") | ||
| tk.MustQuery("select tidb_encode_index_key('test', 't', 'i', 1, 1);"). | ||
| Check(testkit.Rows("74800000000000006e5f698000000000000001038000000000000001038000000000000001")) | ||
| Check(testkit.Rows("7480000000000000705f698000000000000001038000000000000001038000000000000001")) | ||
|
|
||
| tk.MustExec("create table t1 (a int primary key, b int) partition by hash(a) partitions 4;") | ||
| tk.MustExec("insert into t1 values (1, 1);") | ||
| tk.MustQuery("select tidb_encode_record_key('test', 't1(p1)', 1);").Check(testkit.Rows("7480000000000000735f728000000000000001")) | ||
| rs := tk.MustQuery("select tidb_mvcc_info('74800000000000006f5f728000000000000001');") | ||
| tk.MustQuery("select tidb_encode_record_key('test', 't1(p1)', 1);").Check(testkit.Rows("7480000000000000755f728000000000000001")) | ||
| rs := tk.MustQuery("select tidb_mvcc_info('74800000000000007f5f728000000000000001');") | ||
| mvccInfo := rs.Rows()[0][0].(string) | ||
| require.NotEqual(t, mvccInfo, `{"info":{}}`) | ||
|
|
||
|
|
@@ -1772,14 +1772,14 @@ func TestTiDBEncodeKey(t *testing.T) { | |
| tk2 := testkit.NewTestKit(t, store) | ||
| err = tk2.Session().Auth(&auth.UserIdentity{Username: "alice", Hostname: "localhost"}, nil, nil, nil) | ||
| require.NoError(t, err) | ||
| err = tk2.QueryToErr("select tidb_mvcc_info('74800000000000006f5f728000000000000001');") | ||
| err = tk2.QueryToErr("select tidb_mvcc_info('74800000000000007f5f728000000000000001');") | ||
| require.ErrorContains(t, err, "Access denied") | ||
| err = tk2.QueryToErr("select tidb_encode_record_key('test', 't1(p1)', 1);") | ||
| require.ErrorContains(t, err, "SELECT command denied") | ||
| err = tk2.QueryToErr("select tidb_encode_index_key('test', 't', 'i1', 1);") | ||
| require.ErrorContains(t, err, "SELECT command denied") | ||
| tk.MustExec("grant select on test.t1 to 'alice'@'%';") | ||
| tk2.MustQuery("select tidb_encode_record_key('test', 't1(p1)', 1);").Check(testkit.Rows("7480000000000000735f728000000000000001")) | ||
| tk2.MustQuery("select tidb_encode_record_key('test', 't1(p1)', 1);").Check(testkit.Rows("7480000000000000755f728000000000000001")) | ||
| } | ||
|
|
||
| func TestIssue9710(t *testing.T) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -759,7 +759,7 @@ const ( | |
| extra json, -- for the cloud env to save more info like RU, cost_saving, ... | ||
| index idx_create(created_at), | ||
| index idx_update(updated_at), | ||
| unique index idx(schema_name, table_name, index_columns))` | ||
| unique index idx(schema_name, table_name, index_columns));` | ||
|
|
||
| // CreateKernelOptionsTable is a table to store kernel options for tidb. | ||
| CreateKernelOptionsTable = `CREATE TABLE IF NOT EXISTS mysql.tidb_kernel_options ( | ||
|
|
@@ -769,7 +769,18 @@ const ( | |
| updated_at datetime, | ||
| status varchar(128), | ||
| description text, | ||
| primary key(module, name))` | ||
| primary key(module, name));` | ||
|
|
||
| // CreateTiDBWorkloadValuesTable is a table to store workload-based learning values for tidb. | ||
| CreateTiDBWorkloadValuesTable = `CREATE TABLE IF NOT EXISTS mysql.tidb_workload_values ( | ||
| id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
elsa0520 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| version bigint(20) NOT NULL, | ||
| category varchar(64) NOT NULL, | ||
| type varchar(64) NOT NULL, | ||
| table_id bigint(20) NOT NULL, | ||
| value json NOT NULL, | ||
| index idx_version_category_type (version, category, type), | ||
| index idx_table_id (table_id));` | ||
| ) | ||
|
|
||
| // CreateTimers is a table to store all timers for tidb | ||
|
|
@@ -1247,6 +1258,7 @@ const ( | |
|
|
||
| // version 242 | ||
| // insert `cluster_id` into the `mysql.tidb` table. | ||
| // Add workload-based learning system tables | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v242 is introduced by #59511 recently, better to add a temporary comment which will be reduced when WBL is ready to go. In case of the author will curious about the change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid unnecessary version growth, I will share this version before releasing it. |
||
| version242 = 242 | ||
| ) | ||
|
|
||
|
|
@@ -3345,8 +3357,8 @@ func upgradeToVer242(s sessiontypes.Session, ver int64) { | |
| if ver >= version242 { | ||
| return | ||
| } | ||
|
|
||
| writeClusterID(s) | ||
| mustExecute(s, CreateTiDBWorkloadValuesTable) | ||
| } | ||
|
|
||
| // initGlobalVariableIfNotExists initialize a global variable with specific val if it does not exist. | ||
|
|
@@ -3503,6 +3515,8 @@ func doDDLWorks(s sessiontypes.Session) { | |
| mustExecute(s, CreateIndexAdvisorTable) | ||
| // create mysql.tidb_kernel_options | ||
| mustExecute(s, CreateKernelOptionsTable) | ||
| // create mysql.tidb_workload_values | ||
| mustExecute(s, CreateTiDBWorkloadValuesTable) | ||
| } | ||
|
|
||
| // doBootstrapSQLFile executes SQL commands in a file as the last stage of bootstrap. | ||
|
|
||
This file was deleted.
This file was deleted.
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.
as discussed to short the pkg name as wbl as well?
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.
Has been discuss in our group. We will use the workloadlearning uniform