fix: add mysql user-level lock functions#25019
Open
jiangxinmeng1 wants to merge 7 commits into
Open
Conversation
1. RELEASE_LOCK now returns NULL (via isNull flag) when the named lock does not exist or was already released, matching MySQL behavior. When local refcount is 0, the code probes the lockservice with FastFail to distinguish 'lock does not exist' (NULL) from 'lock exists but held by another session' (0). 2. Enforce MySQL-compatible 64-character limit on lock names in getUserLevelLock, releaseUserLevelLock, and isUserLevelLockFree. 3. Add tests: - RELEASE_LOCK on never-created lock returns NULL - RELEASE_LOCK on already-released lock returns NULL - RELEASE_LOCK on lock held by another session returns 0 - Overlong lock names are rejected - Exactly-max-length lock names work Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Replace validateUserLevelLockName with normalizeUserLevelLockName that lowercases names for case-insensitive matching (MySQL requirement). - Enforce 64-character limit using utf8.RuneCountInString (character count), not len() (byte count), matching MySQL's documented behavior. - Reject empty lock names in GET_LOCK, RELEASE_LOCK, and IS_FREE_LOCK. - Add tests for empty-name rejection, case-insensitive contention, and multibyte character boundary (64/65 Chinese characters). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #24728
What this PR does / why we need it:
GET_LOCK,RELEASE_LOCK, andIS_FREE_LOCKbuilt-in functions.