Skip to content
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

Merged
merged 19 commits into from Mar 13, 2023

Conversation

wjhuang2016
Copy link
Member

@wjhuang2016 wjhuang2016 commented Mar 7, 2023

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

  • Unit test
  • Integration test
  • 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

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@wjhuang2016 wjhuang2016 requested a review from a team as a code owner March 7, 2023 07:56
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 7, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • XuHuaiyu
  • zimulala

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.

@ti-chi-bot ti-chi-bot added do-not-merge/invalid-title do-not-merge/needs-linked-issue release-note-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 7, 2023
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016 wjhuang2016 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 7, 2023
@ti-chi-bot ti-chi-bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-triage-completed labels Mar 7, 2023
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016 wjhuang2016 changed the title WIP *: implement global task manager and sub task manager Mar 7, 2023
@wjhuang2016 wjhuang2016 changed the title *: implement global task manager and sub task manager *: implement a global task manager and a sub task manager to handle the read/write of global task table and sub-task table Mar 7, 2023
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@purelind
Copy link
Contributor

purelind commented Mar 7, 2023

/retest

disttask/framework/storage/table_test.go Show resolved Hide resolved
return task, nil
}

// GetTaskByID gets the task by the global task id.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/id/ID

);`

// CreateSubTask is a table about sub-task.
CreateSubTask = `CREATE TABLE IF NOT EXISTS mysql.tidb_sub_task (
Copy link
Contributor

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>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
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) {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 9, 2023
@@ -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 {
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

session/bootstrap_test.go Show resolved Hide resolved
disttask/framework/storage/table_test.go Show resolved Hide resolved
disttask/framework/storage/table_test.go Show resolved Hide resolved
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@wjhuang2016
Copy link
Member Author

/retest

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 9, 2023
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)
Copy link
Contributor

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.

@ti-chi-bot ti-chi-bot removed the status/LGT2 Indicates that a PR has LGTM 2. label Mar 9, 2023
type VARCHAR(256) NOT NULL,
dispatcher_id VARCHAR(256),
state VARCHAR(64) NOT NULL,
start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Copy link
Contributor

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?

@zimulala
Copy link
Contributor

PTAL @wjhuang2016

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 10, 2023
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 10, 2023
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 10, 2023
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 13, 2023
@wjhuang2016
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 81b824e

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 13, 2023
@wjhuang2016
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot merged commit 6c03f5e into pingcap:master Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the simplest logical flow(run through demo normally) for storage
7 participants