pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://tidbcloud.com/free-trial
https://pingcap.com
Apache License 2.0
36.27k stars 5.72k forks source link

infoschema: keep the timestamp of infoschema v2 updating #52983

Closed tiancaiamao closed 1 week ago

tiancaiamao commented 2 weeks ago

What problem does this PR solve?

Issue Number: close #52683 ref #50959

Problem Summary:

It's casued by compatibility issue between infoschema v2 and GC worker. For infoschema v2, it contains a ts field, SchemaTables and loadTableInfo need this ts to get the corresponding schema meta snapshot.

We store the schemaTS as the ts of an infoschema v2 object in the past.

Whether it's schemaTS or startTS does not matter, because they both use the same schema version and data. But when we're using schemaTS, it's not up to date.

For example, a DDL happened 30 minutes ago. (so the ts of infoschema v2 object is 30 min ago) GC happened 10 minutes ago.

Now we get the infoschema v2 object, and use it, we would get the "GC life time is shorter than transaction duration" error.

What changed and how does it work?

Instead of using schemaTS for infoschema v2 object, we can change to use startTS, and keep the startTS updating in domain load schema loop periodically. So that we can get rid of the "GC life time is shorter than transaction duration" error.

Check List

Tests

Start a cluster and wait for GC, and see no panic. Not easy to do that in unit test because GC is mocked and not really the same as real tikv.

Side effects

Documentation

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None
tiprow[bot] commented 2 weeks ago

Hi @tiancaiamao. 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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 55.8355%. Comparing base (40c81c0) to head (27ec2c8). Report is 39 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #52983 +/- ## ================================================= - Coverage 72.3860% 55.8355% -16.5505% ================================================= Files 1482 1620 +138 Lines 428754 615656 +186902 ================================================= + Hits 310358 343755 +33397 - Misses 99088 248679 +149591 - Partials 19308 23222 +3914 ``` | [Flag](https://app.codecov.io/gh/pingcap/tidb/pull/52983/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [integration](https://app.codecov.io/gh/pingcap/tidb/pull/52983/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `38.0545% <91.6666%> (?)` | | | [unit](https://app.codecov.io/gh/pingcap/tidb/pull/52983/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `71.2309% <100.0000%> (+0.0055%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap#carryforward-flags-in-the-pull-request-comment) to find out more. | [Components](https://app.codecov.io/gh/pingcap/tidb/pull/52983/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [dumpling](https://app.codecov.io/gh/pingcap/tidb/pull/52983/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `53.9957% <ø> (ø)` | | | [parser](https://app.codecov.io/gh/pingcap/tidb/pull/52983/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `∅ <ø> (∅)` | | | [br](https://app.codecov.io/gh/pingcap/tidb/pull/52983/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `42.5386% <ø> (+1.3712%)` | :arrow_up: |
ti-chi-bot[bot] commented 1 week ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, ywqzzy

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: - ~~[pkg/domain/OWNERS](https://github.com/pingcap/tidb/blob/master/pkg/domain/OWNERS)~~ [GMHDBJD] - ~~[pkg/infoschema/OWNERS](https://github.com/pingcap/tidb/blob/master/pkg/infoschema/OWNERS)~~ [GMHDBJD,ywqzzy] 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[bot] commented 1 week ago

[LGTM Timeline notifier]

Timeline: