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

*: remove call of SchemaTableInfos for CheckPlacementPolicy #55679

Merged
merged 6 commits into from
Sep 2, 2024

Conversation

joechenrh
Copy link
Contributor

@joechenrh joechenrh commented Aug 27, 2024

What problem does this PR solve?

Issue Number: ref #55394

Problem Summary:

What changed and how does it work?

ReplaceSchemaTableInfos with ListTablesWithSpecialAttribute to get table infos.

Currently, CheckPlacementPolicyNotInUseFromInfoSchema will fetch table infos from meta, which makes it no different from CheckPlacementPolicyNotInUseFromMeta.

func checkPlacementPolicyNotInUse(infoCache *infoschema.InfoCache, t *meta.Meta, policy *model.PolicyInfo) error {
currVer, err := t.GetSchemaVersion()
if err != nil {
return err
}
is := infoCache.GetLatest()
if is != nil && is.SchemaMetaVersion() == currVer {
err = CheckPlacementPolicyNotInUseFromInfoSchema(is, policy)
} else {
err = CheckPlacementPolicyNotInUseFromMeta(t, policy)
}
if err != nil {
return err
}
return checkPlacementPolicyNotInUseFromRange(policy)
}

Additionally, a new function GetTableInfoWithAttributes is added to meta module to retrieve tables with special attributes under certain db.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Test using the following SQLs:

mysql> use test
Database changed

mysql> CREATE PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4;
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE PLACEMENT POLICY p3 FOLLOWERS=4;
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE TABLE t1 (a INT) PLACEMENT POLICY=p3;
Query OK, 0 rows affected (0.03 sec)

mysql> drop placement policy p1;
Query OK, 0 rows affected (0.05 sec)

mysql> drop placement policy p3;
ERROR 8241 (HY000): Placement policy 'p3' is still in use

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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-tests-checked size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 27, 2024
Copy link

tiprow bot commented Aug 27, 2024

Hi @joechenrh. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 6 lines in your changes missing coverage. Please review.

Project coverage is 57.5949%. Comparing base (e72089d) to head (cc0536d).
Report is 38 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #55679         +/-   ##
=================================================
- Coverage   74.9564%   57.5949%   -17.3615%     
=================================================
  Files          1580       1710        +130     
  Lines        367276     626154     +258878     
=================================================
+ Hits         275297     360633      +85336     
- Misses        72206     241593     +169387     
- Partials      19773      23928       +4155     
Flag Coverage Δ
integration 39.3173% <61.9047%> (?)
unit 73.0315% <85.7142%> (-0.9219%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9567% <ø> (-2.2327%) ⬇️
parser ∅ <ø> (∅)
br 60.4640% <ø> (+12.6881%) ⬆️

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 27, 2024
@joechenrh
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Aug 27, 2024
@joechenrh
Copy link
Contributor Author

/retest-required

}
for _, tblInfo := range tblInfos {
schemaTables := is.ListTablesWithSpecialAttribute(infoschema.AllPlacementPolicyAttribute)
for _, schemaTable := range schemaTables {
Copy link
Member

Choose a reason for hiding this comment

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

Should we filter with dbInfo.Name here?

Copy link
Contributor Author

@joechenrh joechenrh Aug 28, 2024

Choose a reason for hiding this comment

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

Here just retrieve and check all tables with necessary attributes, so it's seperated from the previous loop which checks policy at schema level.

@joechenrh
Copy link
Contributor Author

/retest-required

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 28, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 2, 2024
Copy link

ti-chi-bot bot commented Sep 2, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-28 06:44:38.288938268 +0000 UTC m=+939073.423388381: ☑️ agreed by CbcWestwolf.
  • 2024-09-02 07:33:43.381088085 +0000 UTC m=+256947.899141008: ☑️ agreed by tiancaiamao.

@Benjamin2037
Copy link
Collaborator

/approve

@ti-chi-bot ti-chi-bot bot added the approved label Sep 2, 2024
Copy link

ti-chi-bot bot commented Sep 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, CbcWestwolf, tangenta, tiancaiamao

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fzzf678
Copy link
Contributor

fzzf678 commented Sep 2, 2024

It seems no unit test added in this pr, please update the Check List in description

@ti-chi-bot ti-chi-bot bot merged commit d88c42c into pingcap:master Sep 2, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants