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

infoschema, executor, txn: implement DATA_LOCK_WAITS table #24750

Merged
merged 24 commits into from
May 27, 2021

Conversation

longfangsong
Copy link
Contributor

@longfangsong longfangsong commented May 19, 2021

What problem does this PR solve?

We are going to implement the feature Lock View.

A part of it is to support display information about current lock waiting.

What is changed and how it works?

What's Changed:
Just implement the DATA_LOCK_WAITS table.

How it Works:

Add an API in Storage interface for querying lock waits info and do the query when requested.

Related changes

(the following pr need to be merged first)

  • PR on TiKV to export get_lock_wait_info API.

Check List

Tests

  • Unit test
  • Integration test(WIP)

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM

Release note

  • Add DATA_LOCK_WAITS table

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 19, 2021
@github-actions github-actions bot added sig/execution SIG execution sig/sql-infra SIG: SQL Infra labels May 19, 2021
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 20, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 20, 2021
@longfangsong longfangsong changed the title txn: implement DATA_LOCK_WAITS table infoschema, executor, txn: implement DATA_LOCK_WAITS table May 20, 2021
@MyonKeminta MyonKeminta mentioned this pull request May 20, 2021
20 tasks
@longfangsong longfangsong marked this pull request as ready for review May 20, 2021 08:51
@longfangsong longfangsong requested a review from a team as a code owner May 20, 2021 08:51
@longfangsong longfangsong requested review from wshwsh12 and removed request for a team May 20, 2021 08:51
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 20, 2021
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 21, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 21, 2021
@longfangsong longfangsong force-pushed the lock-wait-table branch 5 times, most recently from 0cb2fa3 to 2d156a3 Compare May 21, 2021 06:12
Comment on lines 338 to 353
// GetLockWaits get return lock waits info
func (s *tikvStore) GetLockWaits() ([]*deadlockPB.WaitForEntry, error) {
stores := s.GetRegionCache().GetStoresByType(tikvrpc.TiKV)
var resp *tikvrpc.Response
var err error
for _, store := range stores {
resp, err = s.GetTiKVClient().SendRequest(context.TODO(), store.Addr, tikvrpc.NewRequest(tikvrpc.CmdLockWaitInfo, &kvrpcpb.GetLockWaitInfoRequest{}), time.Second*30)
if err == nil {
break
}
}
if resp == nil {
return nil, err
}
return resp.Resp.(*kvrpcpb.GetLockWaitInfoResponse).Entries, nil
}
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 just noticing that there are several problems:

  • If the cluster is large and the transactions conflict very frequently, is it possible that the amount of lock waiting will be too large, and consumes too much memory in TiDB? Perhaps the problem is not that bad since the deadlock detector works well.
  • We didn't set a limit of entries returned by the GetLockWaitInfo request. But is it possible that there are too many lock wait entries in a single TiKV node, and scanning so many entries occupies the lock manager's thread for too long and increases the node's latency?

PTAL @youjiali1995

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok for now, but we should file issues for potential risks of the feature.

@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 27, 2021
@ti-chi-bot
Copy link
Member

@youjiali1995: Thanks for your review. The bot only counts /lgtm from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

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.

@MyonKeminta MyonKeminta added the sig/transaction SIG:Transaction label May 27, 2021
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 27, 2021
@MyonKeminta
Copy link
Contributor

Please also fix the test caused by removing the HASH column. Rest LGTM.

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • MyonKeminta
  • 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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 May 27, 2021
@MyonKeminta
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: ee154c1

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 27, 2021
@MyonKeminta
Copy link
Contributor

/run-mybatis-test

@MyonKeminta
Copy link
Contributor

MyonKeminta commented May 27, 2021

😕 I don't understand what's wrong with mybatis-test
@cfzjywxk Do you have any idea?

@cfzjywxk
Copy link
Contributor

cfzjywxk commented May 27, 2021

😕 I don't understand what's wrong with mybatis-test
@cfzjywxk Do you have any idea?

That's strange, it seems not related to this PR from the error messages .

Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ibtest.numerics' doesn't exist

@cfzjywxk
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@longfangsong: 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
Copy link
Member

/run-all-tests

This bot automatically retries jobs that failed on can merge PRs (send feedback to hi-rustin).

Silence the bot with the /merge cancel comment for consistent failures.

@ti-chi-bot ti-chi-bot merged commit e87d035 into pingcap:master May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/sql-infra SIG: SQL Infra sig/transaction SIG:Transaction size/L Denotes a PR that changes 100-499 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.

5 participants