-
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: add sync bundles logic for creating and droping #28037
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. |
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
After you have format title, you can leave a comment |
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.
My biggest concern is about policyDependencies
in infoschema. Infoschema is neither persistent, nor strong consistent. It is tricky to use it broadcast events. It becomes the new all-in-one cache while it is designed to sync our old table/pt/db meta changes.
In fact, I wanted to remove all tricky bundle sync in infoschema by persisting more things on TiKV. But it is gone due to cyclic import between parser and TiDB.
Maybe storing ids in the meta info of policy is good and fast enough. Something like push another DDL job that will add affected ids into policy meta when binding a policy.
6314266
to
1cace4a
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>
ddl/placement_policy.go
Outdated
} | ||
// Do the http request only when the rules is existed. | ||
bundles := make([]*placement.Bundle, 0, len(ids)) | ||
for _, id := range ids { |
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 id list contains database ids. However db do not have records stored in tikv
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.
Nice insight, the work is also a preparation for what is coming from @zhaoxugang / @mattias who are under the db policy work
} | ||
if bundle == nil { | ||
// get the default bundle from DB or PD. | ||
bundle = infoschema.GetBundle(d.infoCache.GetLatest(), []int64{schemaID}) |
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.
Why not generating the default bundle using the schema's meta.
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 we can, copyed from wanghe's work for simplicity.
cases is that: once schema did not set a policy, here may need a default bundle with PDBundleID
(also from cache or via http to pd).
cache problem may be your concern, I will change this when all to-do things are much more clear.
/run-all-tests |
Signed-off-by: ailinkid <314806019@qq.com>
… table id Signed-off-by: ailinkid <314806019@qq.com>
656800f
to
21bb88a
Compare
Some logics are still need to be refactor because this implement is based on the legacy code. The refactor can be done in later pull requests. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 078fe50
|
Why need to add a rule to PD when creating a table? |
Signed-off-by: ailinkid 314806019@qq.com
What problem does this PR solve?
Issue Number: close #26580, #28058
Create table with placement policy or direct placement options should sync PD about the rules.
Drop table with placement policy or direct placement options should clean PD about the rules.
Also add a cache map about the policy reference relationship
What is changed and how it works?
What's Changed:
Create table with placement policy or direct placement options should sync PD about the rules.
Drop table with placement policy or direct placement options should clean PD about the rules.
Check List
Tests
Release note