-
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: implement the placement rules inheritance logic #28365
ddl: implement the placement rules inheritance logic #28365
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. |
a4b412d
to
914db2d
Compare
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.
I think it makes sense that we have a function like Bundle.SetType(db | tbl)
. But that can be done later.
/run-check_dev |
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.
Please:
- Refactor
Reset(index, ids...int64)
, remove/integrateAppend
andxxxBundleWrapper
within it. For simplicity, better keep only one reset function. - Remove all
bundle.Tidy()
, move them intoinfosync.PutRuleBundles
. - Remove
checkPolicyValidation
here, it is duplicated because ofNewBundleFromOptions
.
The code will be much simpler with above changes.
ddl/table.go
Outdated
err = bundle.Tidy() | ||
if err != nil { | ||
return nil, errors.Trace(err) | ||
} |
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.
Reset
first, then Tidy
. Maybe we could move all Tidy
to infosync.PutRuleBundles
.
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.
Tidy first is reasonable. Since tidy wanna append a NotIn TiFlash
rule, it should be done before reset work.
The later will clone all these rule for other new ids. otherwise, we should append NotIn TiFlash
rule for every independent id inferred from startKey/ EndKey
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.
Tidy was intended to be used as an post-optimization. Maybe we should move the append of -engine=tiflash
into reset.
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.
I put it into the new bundle portal function --- NewBundleFromOptions
, which are much more clear.
placement-rules-inheritance-test.md here is the manual test script and test results |
rule.GroupID = b.ID | ||
rule.StartKeyHex = startKey | ||
rule.EndKeyHex = endKey | ||
func (b *Bundle) Reset(ruleIndex int, newIDs []int64) *Bundle { |
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.
The current code about bundles seems some what weird and a little complex now. How about refactoring them to below methods:
// Build bundle from table info, and the partition rules and included in the return
NewBundleFromTable(tbl *model.TableInfo) (*Bundle, error)
// Build bundle from partition
NewBundleFromPartition(partition *model.PartitionDefinition) (*Bundle, error)
I think the above methods is enough for ddl to use. It's not necessary to use BundleByName
in infoschema because we'll finally delete it and the logic that directly building bundle from meta is more brief and easy to maintain.
We do not need method Tidy
too. We can tidy
the bundle when we constructing it, I think no where requires a not tidied bundle.
Another advices is the reuse of the code, for example, we can introduce a private method like
newBundleFromPolicyOrDirectOptions(infoschema.InfoSchema, *model.PolicyRefInfo, *model.PlacementSettings) (*Bundle, error)
It will return a semi-finished Bundle and just for code reuse and it should only be visible in placement package
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.
1: refactored to func NewBundleFromTblInfo(t *meta.Meta, job *model.Job, tbInfo *model.TableInfo)
and func NewBundleFromPartition(t *meta.Meta, job *model.Job, partition *model.PartitionInfo)
2: tidy moved to constructors--- NewBundleFromOptions
3: the newBundleFromPolicyOrDirectOptions
function is built
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.
@AilinKid, where is the change of 2? I don't see that.
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.
added, missed in my commits
7eec66d
to
3c72015
Compare
Signed-off-by: ailinkid <314806019@qq.com>
Signed-off-by: ailinkid <314806019@qq.com>
Signed-off-by: ailinkid <314806019@qq.com>
Signed-off-by: ailinkid <314806019@qq.com>
Signed-off-by: ailinkid <314806019@qq.com>
Signed-off-by: ailinkid <314806019@qq.com>
Signed-off-by: ailinkid <314806019@qq.com>
08d26e7
to
247a8df
Compare
Signed-off-by: ailinkid <314806019@qq.com>
173a4d0
to
ad907f3
Compare
/run-check_dev_2 |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 6806823
|
Signed-off-by: ailinkid 314806019@qq.com
What problem does this PR solve?
Issue Number: close #28364
What is changed and how it works?
How it Works:
avoid to write the default placement bundle to pd again when creating table
Check List
Tests
Inaddition:
placement-rules-inheritance-test
Release note