When creating domain, data loss can occur if _civicrm_load_navigation() deadlocks or fails
I've routinely had problems with the civicrm_api3_multisite_domain_create($params) API call because it would result in a MySQL deadlock error that I traced to the _civicrm_load_navigation() call.
When this occurs, the link between the domain_group_id and domain_id is lost because the civicrm_api3('Setting', 'create', ...)
call occurs only after _civicrm_load_navigation(), and outside of the DB transaction.
To resolve this, I've moved the civicrm_api3('Setting', 'create', ...)
call into the transaction, and the _civicrm_load_navigation() outside of the transaction. See !10 (merged) for a merge request to resolve this.
(And since the _civicrm_load_navigation()
seems prone to deadlock in this scenario, I'll separately open an issue to suggest an optional skip_nav
parameter which bypasses _civicrm_load_navigation()
.)