Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Lock] Better key naming when possible#60526

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sylfabre wants to merge1 commit intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromsylfabre:lock_key_name

Conversation

sylfabre
Copy link
Contributor

@sylfabresylfabre commentedMay 23, 2025
edited by nicolas-grekas
Loading

QA
Branch?7.4
Bug fix?no
New feature?no
Deprecations?no
IssuesFix#57906
LicenseMIT

Use plain text for key names when they are short enough.

It helps to understand where inserted locks come from when looking at the database.

See#57906 for examples of how the locks look like in the database.

Use plain text for key name when they are short enough.It helps to understand where inserted locks come from when looking at the database.
@sylfabre
Copy link
ContributorAuthor

I'm not sure how to test this change, any feedback/tips are welcome!

@@ -48,8 +48,12 @@ private function init(array $options, float $gcProbability, int $initialTtl): vo
/**
* Returns a hashed version of the key.
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to be adjusted

@stof
Copy link
Member

This creates collisions for keys, as a long key is not considered the same resource than its hash.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

I'm not sure I see what you mean@stof, can you please expand a bit?

Is there a reasonable case where the key could contain something binary? Shouldn't we hash it when it happens?

Comment on lines +51 to 57
private functiongetKeyName(Key $key): string
{
$keyAsString = (string) $key;
if (strlen($keyAsString) <= 64) {
return $keyAsString;
}
return hash('sha256', (string) $key);

Choose a reason for hiding this comment

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

It'd keep the original name + leverage PHP to do the cast:

Suggested change
privatefunction getKeyName(Key$key):string
{
$keyAsString = (string)$key;
if (strlen($keyAsString) <=64) {
return$keyAsString;
}
returnhash('sha256', (string)$key);
privatefunction getHashedKey(string$key):string
{
returnstrlen($keyAsString) <=64 ?$key :hash('sha256',$key);

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@OskarStarkOskarStarkOskarStark left review comments

@jderussejderusseAwaiting requested review from jderussejderusse is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

[Lock] MySQL reports deadlocks which are difficult to investigate
6 participants
@sylfabre@stof@nicolas-grekas@OskarStark@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp