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

*: TIDB_DECODE_KEY(): Decode keys which only have a TableID #29522

Merged
merged 6 commits into from
Nov 7, 2021

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Nov 5, 2021

What problem does this PR solve?

The TIDB_DECODE_KEY() function was only able to decode keys that were "record" or "index" keys. However the START_KEY and END_KEY columns of information_schema.TIKV_REGION_STATUS always have entries that only have a "table_id" and no row/index info. This is for the minimum start key and the maximum end key.

This change:

  • Helps to decode entries that only have an table_id like 7480000000000000FF4700000000000000F8
  • Removes warnings for calling TIDB_DECODE_ROW() on the minimum START_KEY and maximum END_KEY.
  • Removes invalid JSON values that are returned by TIDB_DECODE_ROW() for the minimum START_KEY and maximum END_KEY. This allows one to use JSON functions directly without having to use IF(JSON_VALID(),...

This is related to pingcap/docs#6728

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code
sql> SELECT TIDB_DECODE_KEY('7480000000000000FF4700000000000000F8');
+---------------------------------------------------------+
| TIDB_DECODE_KEY('7480000000000000FF4700000000000000F8') |
+---------------------------------------------------------+
| {"table_id":71}                                         |
+---------------------------------------------------------+
1 row in set (0.0013 sec)

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

TIDB_DECODE_KEY() now works on keys that only have a Table ID

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 5, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • kennytm
  • tangenta

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 release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 5, 2021
@dveeden
Copy link
Contributor Author

dveeden commented Nov 5, 2021

/cc @kolbe

@ti-chi-bot ti-chi-bot requested a review from kolbe November 5, 2021 09:36
@dveeden
Copy link
Contributor Author

dveeden commented Nov 5, 2021

/cc @tangenta

@ti-chi-bot ti-chi-bot requested a review from tangenta November 5, 2021 09:38
@dveeden
Copy link
Contributor Author

dveeden commented Nov 5, 2021

/run-check_dev
/run-check_dev_2

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 6, 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 Nov 6, 2021
@tangenta
Copy link
Contributor

tangenta commented Nov 7, 2021

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: e264bb0

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

@dveeden: 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.

@kennytm
Copy link
Contributor

kennytm commented Nov 7, 2021

/run-check_dev_2

🤔 https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_check_2/detail/tidb_ghpr_check_2/43863/pipeline

[2021-11-07T15:38:01.515Z] --- FAIL: TestCacheTableBasicScan (3.75s)
[2021-11-07T15:38:01.515Z]     result.go:50: 
[2021-11-07T15:38:01.515Z]         	Error Trace:	result.go:50
[2021-11-07T15:38:01.515Z]         	            				cache_test.go:79
[2021-11-07T15:38:01.515Z]         	            				cache_test.go:113
[2021-11-07T15:38:01.515Z]         	Error:      	Not equal: 
[2021-11-07T15:38:01.515Z]         	            	expected: "[UnionScan 3333.33 root  gt(test.tmp1.id, 4)]\n[└─TableReader 3333.33 root  data:TableRangeScan]\n[  └─TableRangeScan 3333.33 cop[tikv] table:tmp1 range:(4,+inf], keep order:true, stats:pseudo]\n"
[2021-11-07T15:38:01.515Z]         	            	actual  : "[TableReader 3333.33 root  data:TableRangeScan]\n[└─TableRangeScan 3333.33 cop[tikv] table:tmp1 range:(4,+inf], keep order:true, stats:pseudo]\n"
[2021-11-07T15:38:01.515Z]         	            	
[2021-11-07T15:38:01.515Z]         	            	Diff:
[2021-11-07T15:38:01.515Z]         	            	--- Expected
[2021-11-07T15:38:01.515Z]         	            	+++ Actual
[2021-11-07T15:38:01.515Z]         	            	@@ -1,4 +1,3 @@
[2021-11-07T15:38:01.515Z]         	            	-[UnionScan 3333.33 root  gt(test.tmp1.id, 4)]
[2021-11-07T15:38:01.515Z]         	            	-[└─TableReader 3333.33 root  data:TableRangeScan]
[2021-11-07T15:38:01.515Z]         	            	-[  └─TableRangeScan 3333.33 cop[tikv] table:tmp1 range:(4,+inf], keep order:true, stats:pseudo]
[2021-11-07T15:38:01.515Z]         	            	+[TableReader 3333.33 root  data:TableRangeScan]
[2021-11-07T15:38:01.515Z]         	            	+[└─TableRangeScan 3333.33 cop[tikv] table:tmp1 range:(4,+inf], keep order:true, stats:pseudo]

@ti-chi-bot ti-chi-bot merged commit 4df2c21 into pingcap:master Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 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