Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

sylfabre
Copy link
Contributor

@sylfabre sylfabre commented May 23, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? no
Deprecations? no
Issues Fix #57906
License MIT

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.

@sylfabre
Copy link
Contributor Author

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

@stof
Copy link
Member

stof commented May 24, 2025

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

@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
Copy link
Member

@nicolas-grekas nicolas-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?

@sylfabre
Copy link
Contributor Author

@stof May you please elaborate on your comment?

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

Before this change, collisions were possible if two keys shared the same hash (very unlikely, but still possible).

With this change, collisions are possible if:

  • Two large keys shared the same hash (very unlikely, but still possible) => Same as before
  • [New] Or, a 64-character key matches the hash of a large key

Was your comment about this last point?

@stof
Copy link
Member

stof commented Jun 14, 2025

@sylfabre yes, my comment is indeed about that point.

@sylfabre
Copy link
Contributor Author

sylfabre commented Jun 18, 2025

Thanks @stof

I changed the PR

  • <64 chars => I use the plain string
  • >= 64 => I use the hash

This prevents a 64-character plain string from colliding with a hashed large string.

This addresses the issue you pointed out, right?

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
Contributor Author

Thanks @OskarStark for spotting the typos 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lock] MySQL reports deadlocks which are difficult to investigate
6 participants