When running Selenium tests concurrently they sometime choke with a deadlock on the user table.
The issue is INSERT statements share a lock on user_name index and that was found on T199393#4420174 by running a local MariaDB with innodb_print_all_deadlocks which gives a useful trace:
2018-07-12 11:17:06 7f60b4c98700InnoDB: transactions deadlock detected, dumping detailed information. 2018-07-12 11:17:06 7f60b4c98700 *** (1) TRANSACTION: TRANSACTION 36589276, ACTIVE 21 sec inserting mysql tables in use 1, locked 1 LOCK WAIT 4 lock struct(s), heap size 1184, 2 row lock(s), undo log entries 1 MySQL thread id 205, OS thread handle 0x7f60b79d0700, query id 2571 localhost root update INSERT IGNORE INTO `user` (user_name,user_password,user_newpassword,user_email,user_email_authenticated,user_real_name,user_token,user_registration,user_editcount,user_touched) VALUES ('T199393.153140698912290','','','',NULL,'','b0ad88565a69596f779b0eb41607cc12','20180712144949','0','20180712144954') *** (1) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 1189014 page no 4 n bits 144 index `user_name` of table `mywiki`.`user` trx table locks 2 total table locks 4 trx id 36589276 lock_mode X locks gap before rec insert intention waiting lock hold time 4 wait time before grant 0 *** (2) TRANSACTION: TRANSACTION 36589277, ACTIVE 10 sec inserting mysql tables in use 1, locked 1 4 lock struct(s), heap size 1184, 2 row lock(s), undo log entries 1 MySQL thread id 206, OS thread handle 0x7f60b4c98700, query id 2572 localhost root update INSERT IGNORE INTO `user` (user_name,user_password,user_newpassword,user_email,user_email_authenticated,user_real_name,user_token,user_registration,user_editcount,user_touched) VALUES ('T199393.153140698912291','','','',NULL,'','b0ad88565a69596f779b0eb41607cc12','20180712144949','0','20180712144954') *** (2) HOLDS THE LOCK(S): RECORD LOCKS space id 1189014 page no 4 n bits 144 index `user_name` of table `mywiki`.`user` trx table locks 2 total table locks 4 trx id 36589277 lock mode S locks gap before rec lock hold time 10 wait time before grant 0 *** (2) WAITING FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 1189014 page no 4 n bits 144 index `user_name` of table `mywiki`.`user` trx table locks 2 total table locks 4 trx id 36589277 lock_mode X locks gap before rec insert intention waiting lock hold time 0 wait time before grant 0 *** WE ROLL BACK TRANSACTION (2)
It is unclear to whether it ends up in the MediaWiki $wgDBerrorLog or whether we should configure a MariaDB logfile pointing to a file under LOG_DIR.
MariaDB is spawned by Quibble which I think is the best place to add the option. The setting can be enabled using:
/usr/sbin/mysqld --innodb-print-all-deadlocks
There is another option:
--innodb-deadlock-report=name
How to report deadlocks (if innodb_deadlock_detect=ON)
One of: off, basic, full
Mariadb on Debian seems to default to log errors to stdout. They can be redirected to a file using:
--log-error[=name]
Log errors to file (instead of stdout). If file name is not specified then datadir/log-basename.err or the pid-file path with extension .err is used.