mariadb/include/mysql
sjaakola 7bffe468b2 MDEV-21910 Deadlock between BF abort and manual KILL command
When high priority replication slave applier encounters lock conflict in innodb,
it will force the conflicting lock holder transaction (victim) to rollback.
This is a must in multi-master sychronous replication model to avoid cluster lock-up.
This high priority victim abort (aka "brute force" (BF) abort), is started
from innodb lock manager while holding the victim's transaction's (trx) mutex.
Depending on the execution state of the victim transaction, it may happen that the
BF abort will call for THD::awake() to wake up the victim transaction for the rollback.
Now, if BF abort requires THD::awake() to be called, then the applier thread executed
locking protocol of: victim trx mutex -> victim THD::LOCK_thd_data

If, at the same time another DBMS super user issues KILL command to abort the same victim,
it will execute locking protocol of: victim THD::LOCK_thd_data  -> victim trx mutex.
These two locking protocol acquire mutexes in opposite order, hence unresolvable mutex locking
deadlock may occur.

The fix in this commit adds THD::wsrep_aborter flag to synchronize who can kill the victim
This flag is set both when BF is called for from innodb and by KILL command.
Either path of victim killing will bail out if victim's wsrep_killed is already
set to avoid mutex conflicts with the other aborter execution. THD::wsrep_aborter
records the aborter THD's ID. This is needed to preserve the right to kill
the victim from different locations for the same aborter thread.
It is also good error logging, to see who is reponsible for the abort.

A new test case was added in galera.galera_bf_kill_debug.test for scenario where
wsrep applier thread and manual KILL command try to kill same idle victim
2020-07-22 08:20:10 +03:00
..
psi Merge 10.4 into 10.5 2020-07-15 14:51:22 +03:00
auth_dialog_client.h Update FSF address 2019-05-10 20:52:00 +03:00
client_plugin.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
client_plugin.h.pp
plugin.h Part2: MDEV-20837 Add MariaDB_FUNCTION_PLUGIN 2019-10-16 21:47:41 +04:00
plugin_audit.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
plugin_audit.h.pp Adding -D__cplusplus into the ABI check command line 2019-07-11 16:45:18 +04:00
plugin_auth.h Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
plugin_auth.h.pp Adding -D__cplusplus into the ABI check command line 2019-07-11 16:45:18 +04:00
plugin_auth_common.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
plugin_data_type.h cleanup: data type plugins 2019-10-31 11:19:39 +01:00
plugin_data_type.h.pp cleanup: data type plugins 2019-10-31 11:19:39 +01:00
plugin_encryption.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
plugin_encryption.h.pp Adding -D__cplusplus into the ABI check command line 2019-07-11 16:45:18 +04:00
plugin_ftparser.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
plugin_ftparser.h.pp Adding -D__cplusplus into the ABI check command line 2019-07-11 16:45:18 +04:00
plugin_function.h Part1: MDEV-20837 Add MariaDB_FUNCTION_PLUGIN 2019-10-16 21:40:30 +04:00
plugin_function.h.pp Part1: MDEV-20837 Add MariaDB_FUNCTION_PLUGIN 2019-10-16 21:40:30 +04:00
plugin_password_validation.h Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
plugin_password_validation.h.pp Adding -D__cplusplus into the ABI check command line 2019-07-11 16:45:18 +04:00
service_base64.h Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
service_debug_sync.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_encryption.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_encryption_scheme.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_json.h MDEV-5313 Improving audit API. 2019-01-18 03:18:02 +04:00
service_kill_statement.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_logger.h Merge branch '5.5' into 10.1 2019-05-11 19:15:57 +03:00
service_md5.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_my_crypt.h Update WolfSSL 2020-05-08 11:51:03 +02:00
service_my_print_error.h remove incorrect #ifdef 2019-08-26 23:33:42 +02:00
service_my_snprintf.h MDEV-22545: my_vsnprintf behaves not as in C standard 2020-05-24 21:27:08 +02:00
service_progress_report.h Merge branch '5.5' into 10.1 2019-05-11 19:15:57 +03:00
service_sha1.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_sha2.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_thd_alloc.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
service_thd_autoinc.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_thd_error_context.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_thd_mdl.h MDEV-16678 Prefer MDL to dict_sys.latch for innodb background tasks 2019-12-10 15:42:50 +02:00
service_thd_rnd.h Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
service_thd_specifics.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_thd_timezone.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_thd_wait.h Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
service_wsrep.h MDEV-21910 Deadlock between BF abort and manual KILL command 2020-07-22 08:20:10 +03:00
services.h Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00