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
*: implement a global task manager and a sub task manager to handle the read/write of global task table and sub-task table #41979
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
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. Reviewer can indicate their review by submitting an approval review. |
f705872
to
93b922b
Compare
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
/retest |
return task, nil | ||
} | ||
|
||
// GetTaskByID gets the task by the global task id. |
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.
s/id/ID
session/bootstrap.go
Outdated
);` | ||
|
||
// CreateSubTask is a table about sub-task. | ||
CreateSubTask = `CREATE TABLE IF NOT EXISTS mysql.tidb_sub_task ( |
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.
Feeling can use BackgroundSubtaskHistoryTable
directly, because now the table structure in the late may also want to change, that is to change the original directly.
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
} | ||
|
||
// GetNewTask get a new task from global task table, it's used by dispatcher only. | ||
func (stm *GlobalTaskManager) GetNewTask() (task *proto.Task, err error) { |
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.
Is it better to provide a function to get unfinished tasks? Otherwise, when TiDB downs, the task being processed will not get.
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 can be added later when it's needed.
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.
LGTM
@@ -1719,7 +1719,7 @@ func (s *session) ParseWithParams(ctx context.Context, sql string, args ...inter | |||
} else { | |||
stmts, warns, err = s.ParseSQL(ctx, sql, s.sessionVars.GetParseParams()...) | |||
} | |||
if len(stmts) != 1 { | |||
if len(stmts) != 1 && err == nil { |
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.
Do we have a test to test this?
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.
No
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
/retest |
Signed-off-by: wjhuang2016 <huangwenjun1997@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.
LGTM
stm.mu.Lock() | ||
defer stm.mu.Unlock() | ||
|
||
_, err := execSQL(stm.ctx, stm.se, "update mysql.tidb_global_task set state = %?, dispatcher_id = %?, step = %?, state_update_time = %? where id = %?", task.State, task.DispatcherID, task.Step, task.StateUpdateTime.UTC().String(), task.ID) |
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.
This function forgets to update Concurrency
and please add a test.
session/bootstrap.go
Outdated
type VARCHAR(256) NOT NULL, | ||
dispatcher_id VARCHAR(256), | ||
state VARCHAR(64) NOT NULL, | ||
start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, |
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 is not felt necessary to set the default value to "CURRENT_TIMESTAMP"?Now the dispatcher will set the value when it is processed. If it is processed by PR, the default value will be set when it is processed by the client. Is it not as expected?
PTAL @wjhuang2016 |
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 81b824e
|
/retest |
What problem does this PR solve?
Issue Number: close #41984
Problem Summary:
This PR does the following:
1: create a table and modify a table(global task table and sub-task table) when upgrading.
2: Implement a global task manager and a sub-task manager to handle the read/write of these two tables.
3: Add a kv option to represent the distTask type.
4: Fix a tidy bug when handling the parse error, which is annoying if there is any parse error of the internal SQL.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.