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

autoid_service: fix potential autoid decrease when leader change or close for AUTO_ID_CACHE=1 (#52602) #52999

Open ti-chi-bot opened 2 weeks ago

ti-chi-bot commented 2 weeks ago

This is an automated cherry-pick of #52602

What problem does this PR solve?

Issue Number: close #52600

Problem Summary:

What changed and how does it work?

  1. reset map when a node become leader
  2. add lock to protect the map in forceRebase when close

Check List

Tests

See the steps in https://github.com/pingcap/tidb/issues/52600 I'll file another PR to support http API, because it import new changes rather than simple bug fix.

Side effects

Documentation

Release note

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

None
ti-chi-bot[bot] commented 1 week ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Defined2014 Once this PR has been reviewed and has the lgtm label, please ask for approval from tiancaiamao, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[pkg/autoid_service/OWNERS](https://github.com/pingcap/tidb/blob/release-7.5/pkg/autoid_service/OWNERS)** 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:

codecov[bot] commented 1 week ago

Codecov Report

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

:exclamation: No coverage uploaded for pull request base (release-7.5@3df1fe2). Click here to learn what that means.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## release-7.5 #52999 +/- ## ================================================ Coverage ? 72.0038% ================================================ Files ? 1410 Lines ? 409520 Branches ? 0 ================================================ Hits ? 294870 Misses ? 94806 Partials ? 19844 ``` | [Flag](https://app.codecov.io/gh/pingcap/tidb/pull/52999/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/pingcap/tidb/pull/52999/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `72.0038% <100.0000%> (?)` | | 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/52999/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/52999/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `53.9913% <0.0000%> (?)` | | | [parser](https://app.codecov.io/gh/pingcap/tidb/pull/52999/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `∅ <0.0000%> (?)` | | | [br](https://app.codecov.io/gh/pingcap/tidb/pull/52999/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pingcap) | `53.3610% <0.0000%> (?)` | |