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

domain: load all non-public tables into infoschema #55142

Merged
merged 9 commits into from
Sep 5, 2024

Conversation

joechenrh
Copy link
Contributor

@joechenrh joechenrh commented Aug 1, 2024

What problem does this PR solve?

Issue Number: close #54906

What changed and how does it work?

Currently, fetchSchemasWithTables will load non-public schema. This can cause inconsistence between v1 and v2 after drop database and V1V2 consistency check has found several failed cases related to this.

Consider the following sequence of operations:

drop database --> Change to WriteOnly --> Full Load --> Change to DeleteOnly --> ApplyDiff

applyDropSchemaV2 will return all tableIDs in this deleted schema while applyDropSchema will return nothing.

func (b *Builder) applyDropSchemaV2(diff *model.SchemaDiff) []int64 {
di, ok := b.infoschemaV2.SchemaByID(diff.SchemaID)
if !ok {
return nil
}
tableIDs := make([]int64, 0, len(di.Deprecated.Tables))
tables, err := b.infoschemaV2.SchemaTableInfos(context.Background(), di.Name)
terror.Log(err)
for _, tbl := range tables {
tableIDs = appendAffectedIDs(tableIDs, tbl)
}
for _, id := range tableIDs {
b.deleteBundle(b.infoSchema, id)
b.applyDropTableV2(diff, di, id, nil)
}
b.infoData.deleteDB(di, diff.Version)
return tableIDs

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.

You can test it using unit test in this PR: #55030

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 do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Aug 1, 2024
Copy link

ti-chi-bot bot commented Aug 1, 2024

Hi @joechenrh. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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/test-infra repository.

Copy link

tiprow bot commented Aug 1, 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.

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 2, 2024
@wjhuang2016
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Aug 2, 2024
Copy link

codecov bot commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.7243%. Comparing base (487ef06) to head (e138e53).
Report is 5 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #55142         +/-   ##
=================================================
- Coverage   72.8514%   56.7243%   -16.1271%     
=================================================
  Files          1598       1748        +150     
  Lines        444454     627838     +183384     
=================================================
+ Hits         323791     356137      +32346     
- Misses       100734     247142     +146408     
- Partials      19929      24559       +4630     
Flag Coverage Δ
integration 39.6214% <ø> (?)
unit 72.0018% <ø> (+0.0311%) ⬆️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 63.1563% <ø> (+17.3830%) ⬆️

@@ -1043,6 +1043,14 @@ func loadTableInfo(ctx context.Context, r autoid.Requirement, infoData *Data, tb
))
}

// table is not public
if tblInfo.State != model.StatePublic {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it means something wrong if we see the non-public tables?

Do you have any case to cover it? or this is just 'defensive programming'

Copy link
Contributor Author

@joechenrh joechenrh Aug 7, 2024

Choose a reason for hiding this comment

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

Maybe the only case is: user would see table being deleted from information_schema.tables. I'll try to construct this case.

@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 23, 2024
@ti-chi-bot ti-chi-bot bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/needs-triage-completed labels Aug 23, 2024
@joechenrh
Copy link
Contributor Author

/ok-to-test

@joechenrh joechenrh changed the title infoschema: filter non public table in loadTableInfo domain: load all non-public tables into infoschema Sep 3, 2024
@joechenrh
Copy link
Contributor Author

/retest

Copy link

ti-chi-bot bot commented Sep 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tiancaiamao, wjhuang2016

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 4, 2024
Copy link

ti-chi-bot bot commented Sep 4, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-02 02:48:32.484474875 +0000 UTC m=+57709.703236479: ☑️ agreed by wjhuang2016.
  • 2024-09-04 02:48:55.436093034 +0000 UTC m=+412659.954145959: ☑️ agreed by tiancaiamao.

@tiancaiamao
Copy link
Contributor

/retest

2 similar comments
@joechenrh
Copy link
Contributor Author

/retest

@joechenrh
Copy link
Contributor Author

/retest

Copy link

ti-chi-bot bot commented Sep 5, 2024

@joechenrh: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/mysql-test e138e53 link unknown /test mysql-test

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

@joechenrh
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit b04ea3a into pingcap:master Sep 5, 2024
23 of 25 checks passed
breezewish added a commit to breezewish/tidb that referenced this pull request Sep 8, 2024
* origin/master: (33 commits)
  build(deps): bump github.com/prometheus/common from 0.55.0 to 0.57.0 (pingcap#55762)
  build(deps): bump golang.org/x/sys from 0.24.0 to 0.25.0 (pingcap#55894)
  planner: fix incorrect estRows with global index and json column (pingcap#55842)
  ddl, stat: switch to new struct for add/truncate/drop partition (pingcap#55893)
  planner: hide instance plan cache eviction log if no plan is evicted (pingcap#55918)
  expression: support tidb encode key function (pingcap#51678)
  planner: fix incorrect maintenance of `handleColHelper` for recursive CTE (pingcap#55732)
  executor: some code refine of hash join v2 (pingcap#55887)
  infoschema, meta: fix wrong auto id after `rename table` (pingcap#55847)
  ddl/ingest: set `minCommitTS` when detect remote duplicate keys (pingcap#55588)
  planner: move index advisor into the kernel (pingcap#55874)
  ddl, stats: switch to new struct for create/truncate table (pingcap#55811)
  executor: avoid new small objects in probe stage of hash join v2 (pingcap#55855)
  *: Add tidbCPU/tikvCPU into system tables (pingcap#55455)
  ddl: use static contexts in `NewReorgCopContext` (pingcap#55823)
  executor: fix index out of range bug in hash join v2 (pingcap#55864)
  executor: record index usage for the clustered primary keys (pingcap#55602)
  domain: load all non-public tables into infoschema (pingcap#55142)
  test: fix unstable TestShowViewPriv (pingcap#55868)
  ttl: add `varbinary` case for `TestSplitTTLScanRangesWithBytes` (pingcap#55863)
  ...
@joechenrh joechenrh deleted the filter-non-public branch October 12, 2024 08:50
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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

full load doesn't load non-public table
3 participants