MM-21328: Fix KVCompareAndSet when new==old (#13612)
`KVCompareAndSet(key, sameValue, sameValue)` can fail spuriously on MySQL if the underlying `UPDATE` requires no actual changes. As per the [MySQL documentation](https://dev.mysql.com/doc/refman/8.0/en/mysql-affected-rows.html), we can't rely on rows affected in this case: > For UPDATE statements, the affected-rows value by default is the number of rows actually changed. If you specify the CLIENT_FOUND_ROWS flag to mysql_real_connect() when connecting to mysqld, the affected-rows value is the number of rows “found”; that is, matched by the WHERE clause. It's not tenable to change `CLIENT_FOUND_ROWS` for the all connection, so handle this case in the code instead by running a `SELECT` after the fact. Note that `KVCompareAndSet` has no guarantee of atomicity in this case, but neither would `CompareAndSwap` on which this is method was inspired. Finally, note that no changes are required for Postgres, which has sane semantics as the default. Fixes: https://mattermost.atlassian.net/browse/MM-21328 Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c21ea5bc06
Коммит
4314a0427f
@@ -6450,6 +6450,14 @@
|
||||
"id": "store.sql_oauth.update_app.updating.app_error",
|
||||
"translation": "We encountered an error updating the app"
|
||||
},
|
||||
{
|
||||
"id": "store.sql_plugin_store.compare_and_set.mysql_select.app_error",
|
||||
"translation": "Failed to query for existing row on MySQL after KVCompareAndSet with unchanged value."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_plugin_store.compare_and_set.too_many_rows.app_error",
|
||||
"translation": "Found more than 1 row on MySQL after KVCompareAndSet with unchanged value."
|
||||
},
|
||||
{
|
||||
"id": "store.sql_plugin_store.delete.app_error",
|
||||
"translation": "Could not delete plugin key value"
|
||||
|
||||
Ссылка в новой задаче
Block a user