-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
WIP: Proof of concept support for GET_LOCK #33361
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/7bdc76b2c186b53eb2e5aa3938141b9c1cca5a05 |
/run-unit-test |
This implementation is great! |
Thanks for the great work. I have found an implementation differences between this pull request and MySQL. Lock names in TiDB is case-sensitive, while MySQL one is case insensitive. Here are steps to reproduce. TiDB
git clone https://github.com/pingcap/tidb
cd tidb
gh pr checkout 33361
make server
./bin/tidb-server mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.1.0-alpha-31-g7bdc76b2c-dirty
Edition: Community
Git Commit Hash: 7bdc76b2c186b53eb2e5aa3938141b9c1cca5a05
Git Branch: get-lock
UTC Build Time: 2022-03-25 02:57:19
GoVersion: go1.16
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)
mysql>
mysql --comments --host 127.0.0.1 --port 4000 -u root
mysql> select get_lock('foo', -1);
+---------------------+
| get_lock('foo', -1) |
+---------------------+
| 1 |
+---------------------+
1 row in set (0.00 sec)
mysql>
mysql --comments --host 127.0.0.1 --port 4000 -u root
mysql> select get_lock('FOO', -1);
+---------------------+
| get_lock('FOO', -1) |
+---------------------+
| 1 |
+---------------------+
1 row in set (0.00 sec)
mysql> Advisory lock 'foo' and 'FOO' are handled separately. MySQLTested with the same scenario with MySQL, the lock name looks case insensitive.
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.28 |
+-----------+
1 row in set (0.00 sec)
mysql> select get_lock('foo', -1);
+---------------------+
| get_lock('foo', -1) |
+---------------------+
| 1 |
+---------------------+
1 row in set (0.00 sec)
mysql>
mysql> select get_lock('FOO', -1); It waits the lock released named 'foo', it looks like MySQL lock names are case insensitive. |
I have fixed this. PTAL again :-) |
Validated that the advisory lock name is case insensitive. Thanks for the fix. mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.1.0-alpha-32-g3ac96c310-dirty
Edition: Community
Git Commit Hash: 3ac96c310bddd3973fdf000e6f76228e01556747
Git Branch: get-lock
UTC Build Time: 2022-03-28 01:49:17
GoVersion: go1.16
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)
mysql> |
This draft implementation LGTM. |
@morgo: PR needs rebase. 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. |
I am going to close this draft for now. I opened it to prove that it is possible to get this working using pessimistic locks :-) I will clean it up and merge after the proposal has been approved. |
What problem does this PR solve?
Issue Number: ref #14994
Problem Summary:
This is a draft implementation for
GET_LOCK
/RELEASE_LOCK
/RELEASE_ALL_LOCKS
. It doesn't handle all corner cases yet, like deadlocks.What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note