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

executor: Support collecting information about retryable deadlocks to information_schema.deadlocks #26140

Merged
merged 6 commits into from
Jul 22, 2021

Conversation

MyonKeminta
Copy link
Contributor

@MyonKeminta MyonKeminta commented Jul 12, 2021

What problem does this PR solve?

Problem Summary: This PR is part of Lock View. It supports collecting retryable (in-statement) deadlocks. It's by default not collected, but it can be enabled by config.

What is changed and how it works?

What's Changed: Supports collecting retryable deadlock errors.

Check List

Tests

  • Unit test
    • Currently the unit test only covers the config. I tried to construct a retryable deadlock error in unit test, but it was too hard. Considering the code change is simple enough, I abandoned the test in this PR. It will be implemented later, if possible.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory

Documentation

  • Contains configuration changes (?)

Release note

  • Supports collecting information of retryable deadlock errros.

@MyonKeminta MyonKeminta added the sig/transaction SIG:Transaction label Jul 12, 2021
@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 12, 2021
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 15, 2021
rec := deadlockhistory.ErrDeadlockToDeadlockRecord(deadlock)
deadlockhistory.GlobalDeadlockHistory.Push(rec)
cfg := config.GetGlobalConfig()
if deadlock.IsRetryable && !cfg.PessimisticTxn.DeadlockHistoryCollectRetryable {
Copy link
Contributor

Choose a reason for hiding this comment

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

If a retryable deadlock occurs many times, can it pollute the deadlock histroy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. So I make it not collected by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid it's never turned on because it can't be changed online. For retryable deadlock, it's better to merge the error from the same statements and record its retry count.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I plan to make it support online-changing via the http api. But, you are right, merging repeated error is a good idea. I'll reconsider it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make an record to become latest when updating the retry count of an existing record, It seems we need to change the deadlock history collection (which is a simple queue now) into an LRU. @youjiali1995

Copy link
Contributor Author

@MyonKeminta MyonKeminta Jul 21, 2021

Choose a reason for hiding this comment

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

I didn't support merging repeated error for now since it needs too much code change, but I added the HTTP API. PTAL again. @youjiali1995 @longfangsong

@ti-chi-bot ti-chi-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 21, 2021
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • longfangsong
  • youjiali1995

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 22, 2021
@youjiali1995
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: f5444c4

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 22, 2021
@ti-chi-bot
Copy link
Member

@MyonKeminta: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit 2b461e0 into pingcap:master Jul 22, 2021
@MyonKeminta MyonKeminta deleted the m/collect-retryable-deadlock branch July 22, 2021 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/config sig/execution SIG execution sig/sql-infra SIG: SQL Infra sig/transaction SIG:Transaction size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants