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,infoschema: fix 'show tables' after snapshot read #55856

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #55835

Problem Summary:

What changed and how does it work?

loadInfoschema for snapshot infoschema should not be added to schema history.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

It requires restart of tidb, follow the steps in the issue.

  • No need to test
    • I checked and no code files have been changed.

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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 4, 2024
@tiancaiamao
Copy link
Contributor Author

Maybe it will also fix #55486 but maybe not.

@tiancaiamao
Copy link
Contributor Author

Maybe it will also fix #55806 but maybe not.

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.8786%. Comparing base (2e457b3) to head (5753f83).
Report is 4 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #55856         +/-   ##
=================================================
- Coverage   72.9093%   56.8786%   -16.0307%     
=================================================
  Files          1604       1755        +151     
  Lines        446718     630451     +183733     
=================================================
+ Hits         325699     358592      +32893     
- Misses       100964     247179     +146215     
- Partials      20055      24680       +4625     
Flag Coverage Δ
integration 39.5362% <100.0000%> (?)
unit 72.0688% <100.0000%> (+0.0540%) ⬆️

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

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

@tiancaiamao
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Sep 5, 2024

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

// Why? imagine that the current schema version is [103 104 105 ...]
// Then a snapshot read require infoschem version 53, and it's added
// Now the history becomes [53, ... 103, 104, 105 ...]
// Then if a query ask for version 74, we'll mistakenly use 53!
Copy link
Contributor

Choose a reason for hiding this comment

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

And now the query for 74 will fail? Is this expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course not.
Not we get two kinds of infoschema, with non-snapshot one [ ... 103, 104, 105 ...]
and snapshot infoschema contains no history like [53] [74] etc

@@ -533,3 +533,39 @@ func TestSnapshotInfoschemaReader(t *testing.T) {
sql = fmt.Sprintf("select * from INFORMATION_SCHEMA.TABLES as of timestamp '%s' where table_schema = 'issue55827'", timeStr)
tk.MustQuery(sql).Check(testkit.Rows())
}


func TestIssue55835(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The UT can pass without this fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is, when we switch v1/v2 back and forth, the history is not cleared.
So v1/v2 switch can't reproduce the tidb restart scenario.
During adding this test, I did find something wrong: when modify @@tidb_schema_cache_size, without a new DDL operation, v1/v2 switch does not happen, that's not expected.

I confirmed this change can fix the bug and tested manually following the steps described in the issue.

@tiancaiamao
Copy link
Contributor Author

PTAL @lance6716 @wjhuang2016

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 11, 2024
@lance6716
Copy link
Contributor

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 11, 2024
@lance6716
Copy link
Contributor

/lgtm

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

ti-chi-bot bot commented Sep 11, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-11 09:18:50.131925031 +0000 UTC m=+434399.872348968: ☑️ agreed by wjhuang2016.
  • 2024-09-11 09:31:48.618000149 +0000 UTC m=+435178.358424101: ☑️ agreed by lance6716.

Copy link

ti-chi-bot bot commented Sep 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, 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

@tiancaiamao
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 11, 2024
@tiancaiamao
Copy link
Contributor Author

/test check-dev

Copy link

tiprow bot commented Sep 11, 2024

@tiancaiamao: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev

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 merged commit ae8f977 into pingcap:master Sep 11, 2024
23 checks passed
@tiancaiamao tiancaiamao deleted the issue55835 branch September 11, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm 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.

show tables get wrong result after restart tidb and a snapshot read
3 participants