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
MysqlMutext component fix same connection but difference database fail #19603
MysqlMutext component fix same connection but difference database fail #19603
Conversation
kamarton
commented
Oct 3, 2022
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ✔️ |
Breaks BC? | ❌ |
Fixed issues | #19316 |
…l with extended keyPrefix.
This PR is not backwards compatible. If an application would, for example, use different databases for each of it's customers a.k.a. tenants, the mutex would no longer work on the MySQL server level after the implementation of this PR. I think the assumption made in #19316 is incorrect. Different databases should not matter for the mutex, it's the driver for the mutex that determines its scope. So as long as the same endpoint is used the application should be able to count on the mutex behavior of that driver (in this case the MySQL server). If an application needs 2 different scopes for different mutexes as in #19316 the |
I'm not sure if this reasoning is right, are you talking about different connections + different dbs or one connections + different dbs because the one case should be fine here. Or should not? |
@bizley As far as I know both the connection or the database should not make any difference. By default the "scope" of the mutex is "server wide" since the MySQL server itself stores the lock in the "performance_schema" database in the "metadata_locks" table (https://dev.mysql.com/doc/refman/8.0/en/locking-functions.html). Therefore any client, no matter the database (you can even open up a CLI client without using any database), would request the same lock (assuming they use the same name for the lock). So if the default behavior is a "server wide" scope for the uniqueness of a mutex lock this PR would brake that default behavior (and therefore braking backwards compatibility). |
My suggestion would be to remove the default value for the
@samdark You mentioned before that the name should be included (#19316 (comment)), what are your thoughts on this (please see comments above)? |
@rhertogh The problem is that old behavior is unexpected and hard to debug. If you share DB server with others, you may not even be aware the problem, you just get random lock failures out of nowhere. So while this is a BC break, I think that new behavior is more sensible as a default. But this change indeed should be documented in UPGRADE.md. |
@rob006 True, a note in UPGRADE.md could cover it. Another option would be to change the default value from |
@rhertogh do you have time for a pull request with additions to UPGRADE? |
Added UPGRADE.md note since the default "scope" of the yii\mutex\MysqlMutex has changed.
@samdark I've created a PR: #19645 |