-
Notifications
You must be signed in to change notification settings - Fork 21
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
HA#realize(): avoid deadlocks via exclusive locking, i.e. SELECT ... FOR UPDATE #788
base: main
Are you sure you want to change the base?
Conversation
…FOR UPDATE In its transaction, this method always performs a SELECT ... <lock clause> and at least one upsert in the same table. If two instances aquire shared locks, those will deadlock each other during the following upsert.
I have a hard time understanding what the goal of this PR is.
Then how does this avoid deadlocks?
Where exactly does it recommend that? |
It recommends it if one needs exclusive locking. And IMAO our deadlocks come from shared locking. |
You're contradicting yourself! Your PR summary was same result, which to me indicates it's not worth wasting any more time on it. |
Based on the summary within the MySQL Locking Reads documentation, this PR makes sense:
But the "After-behavior: Same result." makes me question things. |
How about trying to add a |
Isn't that new MySQL/MariaDB feature? Server version: 10.2.44-MariaDB-1:10.2.44+maria~bionic mariadb.org binary distribution
...
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOWAIT' at line 1 |
Seems to be unavailable in MySQL 5.7 and MariaDB prior to version 10.3. Are there still any supported distributions shipping those versions? AlmaLinux 8 (being my RHEL-reference) ships, for example, some MariaDB 10.3, 10.5 and 10.11 according to repology. I have only found Amazon 2 Linux as a problem child with some ancient MySQL version. |
Admittedly it looks this way, but I hope that I just haven't found a proper test, yet. FWIW, SLES 12.5 installs mariadb-10.2.44-3.53.1.x86_64 by default, but I guess we can ignore this. |
I don't think you have tested the scenario with the non-empty instance table correctly:
In my opinion, Also, I just started 10 Icinga DB instances each for |
Ping @Al2Klimov |
In its transaction, this method always performs a SELECT ... <lock clause> and at least one upsert in the same table. If two instances aquire shared locks, those will deadlock each other during the following upsert.
Tests (edited)
For completeness, the "INSERT" in question contains "ON DUPLICATE KEY UPDATE" which makes it the "upsert" I mentioned.
Anyway, I'd like to properly use locking as recommended per https://dev.mysql.com/doc/refman/5.7/en/innodb-locking-reads.html