Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Won't Fix
-
Affects Version/s: 4.2.4
-
Fix Version/s: 4.4.0
-
Component/s: None
-
Labels:None
Description
Hi,
So I have used node.js to create contacts https://github.com/tttp/civi-charlatan
it fires several REST requests in parallel. I always have the first few that are in error, that it mostly works but get some more errors later on. It seems to be linked with concurrency, but not 100% sure.
Anyway, that's the error I get:
(that's a pain to debug, you can't json encode in debug mode because the call trace seems to be too big)
So I have seen that deadlock either on:
UPDATE civicrm_contact contact_a,civicrm_contact contact_b\nSET contact_a.employer_id=contact_b.id, contact_a.organization_name=contact_b.organization_name\nWHERE contact_a.id =53 AND contact_b.id=55;
Seems to be from setCurrentEmployee in CRM/Contact/BAO/Contact/Utils.php, that has a todo that I don't understand
//FIXME : currently civicrm mysql_query support only single statement
//execution, though mysql 5.0 support multiple statement execution.
Or on the creation of the employer
INSERT INTO civicrm_contact (contact_type , contact_sub_type , sort_name , display_name , hash , organization_name ) VALUES ('Organization' , NULL , 'Kohler, Bruen and McCullough' , 'Kohler, Bruen and McCullough' , 'c394319089058fdb9e2611921932ec1e' , 'Kohler, Bruen and McCullough' )
I have no idea how to isolate the problem. Do you?
More a workaround than really a fix: it seems the code
1. create the individual,
2. create the organisation then
3. update the individual
Would it be a solution (and better for performance) to change the order so
1. create the organisation
set the employer_id and org name in the individual
2. create the individual