-
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
ddl, session: fix re-upgrade issues #44469
Conversation
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.
Could update job2SchemaNames
function
--- a/ddl/job_table.go
+++ b/ddl/job_table.go
@@ -561,12 +561,12 @@ func job2SchemaNames(job *model.Job) []string {
names = append(names, strings.ToLower(job.SchemaName))
names = append(names, oldSchemaName.O)
return names
- case model.ActionRenameTables:
- // TODO: Get this action's schema names.
- case model.ActionExchangeTablePartition:
+ case model.ActionRenameTables, model.ActionExchangeTablePartition:
// TODO: Get this action's schema names.
+ return nil
+ default:
+ return []string{job.SchemaName}
}
- return []string{job.SchemaName}
}
} | ||
// TODO: consider about model.ActionRenameTables and model.ActionExchangeTablePartition, which need to get the schema names. |
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.
Better one.
If not necessary, we'd better not add the code. "// TODO:" is a option.
It would be much better to talk about such kind of potential possibility in the design procedure, as much as possible.
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.
Yeah, but here I think it needs to be added.
m := meta.NewMeta(txn) | ||
err = m.FinishBootstrap(session.CurrentBootstrapVersion - 1) | ||
require.NoError(t, err) | ||
err = txn.Commit(context.Background()) |
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.
Shall we use the session
but not txn
here, or another session? It would be better use the same mechamism in certain routing.
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 is because this method of FinishBootstrap
call requires txn
.
} | ||
if job.State == model.JobStatePaused && jobID == 0 { | ||
// Mock pause the ddl job by system. | ||
job.AdminOperator = model.AdminCommandBySystem |
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 looks like that would be better to do the real upgrade but not mock since it will be more like user's action.
And, the mock
here normally seems being a litlle bit complex since there are cases that we may not know what will be going to happen in the future because the behavior of 'job.AdminOperator' may be changed by its module. In another word, the case here involves the inside-logic of 'admin pause' which may introduce unknow error in future.
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.
Yes, but the test should fail if the internal implementation changes, so just modify the test. And the way I've come up with mocks so far is this. Do you have any other suggestions?
} | ||
mustExecute(s, "use mysql") | ||
mustExecute(s, `create table if not exists mock_sys_t( | ||
c1 int, c2 int, c3 int, c11 tinyint, index fk_c1(c1) |
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 would be better that different column is with different kind of type
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 is a simple test, hopefully a system DDL job. I don't feel the need to consider these types.
const ( | ||
defaultMockUpgradeToVerLatest = 0 | ||
// MockSimpleUpgradeToVerLatest is used to indicate the use of the simple mock bootstrapVersion. | ||
MockSimpleUpgradeToVerLatest = 1 |
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.
What does it mean 'Simple' here? The function 'mockSimpleUpgradeToVerLatest'?
And, the function and the enum are sharing the same name seems not a good idea.
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.
Comments were added. Another name has a good suggestion can be put forward, I change it
[LGTM Timeline notifier]Timeline:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Defined2014, hawkingrei, XuHuaiyu 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 |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
What problem does this PR solve?
Issue Number: close #44158, and related #44366
Problem Summary:
Mock: do upgradeNewVer: Add a new mysql.table(mock system DDL)
case 1
runDDLJob
.case 2
What is changed and how it works?
runDDLJob
) when upgrading state.Check List
Tests
case 2.
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.