DrupalDriver
DrupalDriver copied to clipboard
Concurrency issue with mail collection
We use core's TestMailCollector for email collection. This simply injects emails into the key_value table by way of the system.test_mail_collector state. When Behat tests are running concurrently, database lock issues can result when too many emails are trying to be written into the same state variable:
General error: 1205 Lock wait timeout exceeded; try restarting transaction: UPDATE {key_value} SET value=:db_update_placeholder_0
WHERE (name = :db_condition_placeholder_0) AND (collection = :db_condition_placeholder_1); Array
(
[:db_update_placeholder_0] => a:2:{i:0;a:13:{s:2:"id";s:34:"user_register_no_approval_required";s:6:"module";s:4:"user";s:3:"key";s:29:"register_no_approval_required";s:2:"to";s:24:"[email protected]";s:4:"from";s:21:"[email protected]";s:8:"reply-to";s:21:"[email protected]";s:8:"langcode";s:2:"en";s:6:"params";a:1:{s:7:"account";O:23:"Drupal\user\Entity\User":27:{s:9:" in
One possible solution would be to implement our own collection that can utilize a randomized state variable per-instance (not sure if this is possible or not with the core email system).