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

util: Fix lock view cannot show key info correctly for partition table (#27027) #27035

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

ti-srebot
Copy link
Contributor

@ti-srebot ti-srebot commented Aug 9, 2021

cherry-pick #27027 to release-5.2
You can switch your code base to this Pull Request by using git-extras:

# In tidb repo:
git pr https://github.com/pingcap/tidb/pull/27035

After apply modifications, you can push your change to this PR via:

git push [email protected]:ti-srebot/tidb.git pr/27035:release-5.2-e539f9d62f87

What problem does this PR solve?

Problem Summary: Currently when using the data_lock_waits and deadlocks table of lock view, if it shows a key from a partitioned table, the key_info column may not show the key's information correctly. It's because Lock View didn't handle these kind of keys correctly. This PR fixes this problem.

What is changed and how it works?

Proposal: xxx

What's Changed: In util/keydecoder, which is specifically used by Lock View for finding information from keys: When failed to find a table by table ID, try to use it as a partition ID and try to find the partition info and its corresponding table info.

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)
/* init */ drop table if exists t;
-- init >> 0 rows affected
/* init */ create table t (id int primary key, uk int, v int, unique key i1 (uk, id)) partition by range (id) ( partition p0 values less than (10), partition p1 values less than maxvalue);
-- init >> 0 rows affected
/* init */ insert into t values (1, 1, 1), (2, 2, 2);
-- init >> 2 rows affected
/* t1:wait */ begin;
-- t1 >> 0 rows affected
/* t1 */ update t set v = v + 1 where id = 1;
-- t1 >> 1 rows affected
/* t2 */ begin;
-- t2 >> 0 rows affected
/* t2 */ update t set v = v + 1 where id = 1;
-- t2 >> blocked
/* t4 */ select * from information_schema.data_lock_waits;
-- t4 >> +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------------+
-- t4    |                  KEY                   |                                                                  KEY INFO                                                                  |       TRX ID       | CURRENT HOLDING TRX ID |                            SQL DIGEST                            |                SQL DIGEST TEXT                |
-- t4    +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------------+
-- t4    | 74800000000000004D5F728000000000000001 | {"db_id":1,"db_name":"test","table_id":76,"table_name":"t","partition_id":77,"partition_name":"p0","handle_type":"int","handle_value":"1"} | 426901898605101059 |     426901898605101057 | 06da614b93e62713bd282d4685fc5b88d688337f36e88fe55871726ce0eb80d7 | update `t` set `v` = `v` + ? where `id` = ? ; |
-- t4    +----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+--------------------+------------------------+------------------------------------------------------------------+-----------------------------------------------+
/* t1 */ rollback;
-- t1 >> 0 rows affected
-- t2 >> resumed
-- t2 >> 1 rows affected

Side effects

  • None

Documentation

  • None

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 9, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • cfzjywxk
  • 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-srebot
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 9, 2021
@ti-srebot ti-srebot added sig/transaction SIG:Transaction size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/5.2-cherry-pick labels Aug 9, 2021
@ti-srebot
Copy link
Contributor Author

@MyonKeminta you're already a collaborator in bot's repo.

@MyonKeminta MyonKeminta added the type/bugfix This PR fixes a bug. label Aug 9, 2021
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 9, 2021
@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 Aug 9, 2021
@cfzjywxk
Copy link
Contributor

cfzjywxk commented Aug 9, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 32a7b1e

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

/merge

@zhouqiang-cl zhouqiang-cl added the cherry-pick-approved Cherry pick PR approved by release team. label Aug 12, 2021
@ti-chi-bot ti-chi-bot merged commit 04d9017 into pingcap:release-5.2 Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. release-note-none Denotes a PR that doesn't merit a release note. 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. type/bugfix This PR fixes a bug. type/5.2-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants