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: add resolve lock logic for mvcc get key loading schema diff #48282

Conversation

cfzjywxk
Copy link
Contributor

@cfzjywxk cfzjywxk commented Nov 3, 2023

What problem does this PR solve?

Issue Number: ref #48281

Problem Summary:
Handle lock error reading mvcc get schema diff key to avoid unexpected schema cache invalidation.

What is changed and how it works?

Check List

Tests

Side effects

Documentation

Release note

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

Fix unhandled lock error reading schema diff key using mvcc interface.

@cfzjywxk cfzjywxk added type/bugfix This PR fixes a bug. sig/transaction SIG:Transaction sig/sql-infra SIG: SQL Infra labels Nov 3, 2023
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 3, 2023
Copy link

tiprow bot commented Nov 3, 2023

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

@cfzjywxk cfzjywxk marked this pull request as draft November 3, 2023 13:00
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 3, 2023
// GetMvccByEncodedKeyWithTS get the MVCC value by the specific encoded key, if lock is encountered it would be resolved.
func (h *Helper) GetMvccByEncodedKeyWithTS(encodedKey kv.Key, startTS uint64) (*kvrpcpb.MvccGetByKeyResponse, error) {
// A derived value from previous implementation possible experiencing value 5000ms.
MaxBackoffTimeout := 5000
Copy link
Contributor

Choose a reason for hiding this comment

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

Extract a const?

helper := helper.NewHelper(tikvStore)
data, err := helper.GetMvccByEncodedKey(m.EncodeSchemaDiffKey(version))
newHelper := helper.NewHelper(tikvStore)
mvccResp, err := newHelper.GetMvccByEncodedKeyWithTS(m.EncodeSchemaDiffKey(version), startTS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just call another GetMvccByEncodedKey(lock.primary) to get the commit-ts? Resolving lock and retring makes GetMvcc complex and heavy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's possible the primary key is not committed or the ongoing internal transaction is invisible to the input start_ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Besides, it's better to use snapshot interfaces instead of the mvcc interfaces, I've filed an issue about it #48283

crazycs520 added a commit to crazycs520/tidb that referenced this pull request Nov 4, 2023
@cfzjywxk cfzjywxk marked this pull request as ready for review November 4, 2023 02:12
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 4, 2023
@crazycs520
Copy link
Contributor

crazycs520 commented Nov 4, 2023

You can found some test result(record) here: #48294

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 4, 2023
@ti-chi-bot ti-chi-bot bot added the lgtm label Nov 6, 2023
Copy link

ti-chi-bot bot commented Nov 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: crazycs520, zyguan

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 6, 2023
Copy link

ti-chi-bot bot commented Nov 6, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-04 05:59:19.396105628 +0000 UTC m=+3278356.983215758: ☑️ agreed by crazycs520.
  • 2023-11-06 08:12:40.229277517 +0000 UTC m=+3459157.816387661: ☑️ agreed by zyguan.

@cfzjywxk cfzjywxk merged commit e811102 into pingcap:tidb-6.5-with-kv-timeout-feature Nov 7, 2023
3 of 7 checks passed
guoshouyan pushed a commit to guoshouyan/tidb that referenced this pull request Mar 5, 2024
…ingcap#48282 (pingcap#18)

* add resolve lock logic for mvcc get key loading schema diff

* adstract a constant

Co-authored-by: cfzjywxk <cfzjywxk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/sql-infra SIG: SQL Infra sig/transaction SIG:Transaction size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants