Answers.Body: <p>It looks like civicrm is trying to record the change as being done with a different id than the contact that is trying to register (381 vs 374)</p>
  
  <p>Are you sure you are properly anonymous? it might be that your site still think you are "someone else" (eg. the contact you deleted?). </p>
  
  <p>Could you try creating a new account from a "clean" computer, or if you can't, try doing it with your computer, but from an anonymous session (each browser has a different way of doing that, in firefox, it's File->New Private window) and see if you experience the same issue?</p>
  
  <p>and if you do, could you temporarily disable the og_sync, to try to narrow down where the problem comes from?</p>
  
  <p>X+</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-11T14:19:47.390Z
Answers.Text: Wohooo!! You are right. I simply took another browser (chrome instead of firefox) and it works again! Strange - since I took firefox's private mode, so I thought cookies cant be the problem... So my paranoia was unjustified.Thanks !
Answers.UserDisplayName: pedral
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-11T14:12:01.670Z
Answers.LastActivityDate: 2016-01-11T14:12:01.670Z
Answers.UserDisplayName: Xavier
Answers.Body: <p>Logging out and back in solved the problem for me.</p>
  
  <p>I had deleted a contact (probably associated contact with the logged in user). And then I began seeing this error.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-07T20:31:39.833Z
Answers.LastActivityDate: 2016-06-07T20:31:39.833Z
Answers.UserDisplayName: Dilip Raj Baral
Body: <p>I am using CiviCRM(4.6.10) with Drupal (7.38) together with the civicrm_og_sync module. Until now everything worked fine:</p>
  
  <p>Everytime a drupal user was created automatically a civi contact was also created. Then I deleted a user account on drupal and the corresponding contact in civi (full deletion!).</p>
  
  <p>Now when I try to create a new user in drupal I get the following error:</p>
  
  <blockquote>
    <p><code>
    Datenbank-Errorcode: Cannot add or update a child row: a foreign key constraint fails (<code>civi_db</code>.<code>civicrm_log</code>, CONSTRAINT <code>FK_civicrm_log_modified_id</code> FOREIGN KEY (<code>modified_id</code>) REFERENCES <code>civicrm_contact</code> (<code>id</code>) ON DELETE CASCADE), 1452
    Zusätzliche Details:
    Array
    (
        [callback] => Array
            (
                [0] => CRM_Core_Error
                [1] => handle
            )
        [code] => -3
        [message] => DB Error: constraint violation
        [mode] => 16
        [debug_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  381 , 'civicrm_contact,381' ,  374 ,  20160111141559 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (<code>civi_db</code>.<code>civicrm_log</code>, CONSTRAINT <code>FK_civicrm_log_modified_id</code> FOREIGN KEY (<code>modified_id</code>) REFERENCES <code>civicrm_contact</code> (<code>id</code>) ON DELETE CASCADE)]
        [type] => DB_Error
        [user_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  381 , 'civicrm_contact,381' ,  374 ,  20160111141559 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (<code>civi_db</code>.<code>civicrm_log</code>, CONSTRAINT <code>FK_civicrm_log_modified_id</code> FOREIGN KEY (<code>modified_id</code>) REFERENCES <code>civicrm_contact</code> (<code>id</code>) ON DELETE CASCADE)]
        [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  381 , 'civicrm_contact,381' ,  374 ,  20160111141559 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (<code>civi_db</code>.<code>civicrm_log</code>, CONSTRAINT <code>FK_civicrm_log_modified_id</code> FOREIGN KEY (<code>modified_id</code>) REFERENCES <code>civicrm_contact</code> (<code>id</code>) ON DELETE CASCADE)]"]
    )
    </code></p>
  </blockquote>
  
  <p>In the end the drupal user is created but not the civi contact. I looked into the tables 'civicrm_contact' and 'civicrm_log' but couldn't find anything supicious - an id or modified_id with number 381 did not exist. On the other hand I can still create a contact with the civi user-interface...</p>
  
  <p>What can I do?</p>
  
Tags: <drupal><contacts><logs>
Title: Cannot add or update a child row: a foreign key constraint fails
ThreadText: # Cannot add or update a child row: a foreign key constraint fails
  
  (Asked by: username_0 on 2016-01-11)
  
  I am using CiviCRM(4.6.10) with Drupal (7.38) together with the civicrm\_og\_sync module. Until now everything worked fine:
  
  Everytime a drupal user was created automatically a civi contact was also created. Then I deleted a user account on drupal and the corresponding contact in civi (full deletion!).
  
  Now when I try to create a new user in drupal I get the following error:
  
  > `Datenbank-Errorcode: Cannot add or update a child row: a foreign key constraint fails (civi_db.civicrm_log, CONSTRAINT FK_civicrm_log_modified_id FOREIGN KEY (modified_id) REFERENCES civicrm_contact (id) ON DELETE CASCADE), 1452
  > Zusätzliche Details:
  > Array
  > (
  > [callback] => Array
  > (
  > [0] => CRM_Core_Error
  > [1] => handle
  > )
  > [code] => -3
  > [message] => DB Error: constraint violation
  > [mode] => 16
  > [debug_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' , 381 , 'civicrm_contact,381' , 374 , 20160111141559 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (civi_db.civicrm_log, CONSTRAINT FK_civicrm_log_modified_id FOREIGN KEY (modified_id) REFERENCES civicrm_contact (id) ON DELETE CASCADE)]
  > [type] => DB_Error
  > [user_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' , 381 , 'civicrm_contact,381' , 374 , 20160111141559 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (civi_db.civicrm_log, CONSTRAINT FK_civicrm_log_modified_id FOREIGN KEY (modified_id) REFERENCES civicrm_contact (id) ON DELETE CASCADE)]
  > [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' , 381 , 'civicrm_contact,381' , 374 , 20160111141559 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (civi_db.civicrm_log, CONSTRAINT FK_civicrm_log_modified_id FOREIGN KEY (modified_id) REFERENCES civicrm_contact (id) ON DELETE CASCADE)]"]
  > )`
  
  In the end the drupal user is created but not the civi contact. I looked into the tables 'civicrm\_contact' and 'civicrm\_log' but couldn't find anything supicious - an id or modified\_id with number 381 did not exist. On the other hand I can still create a contact with the civi user-interface...
  
  What can I do?
  
  **Tags:** drupal, contacts, logs
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-01-11. Score: 2 | Accepted answer
  
  It looks like civicrm is trying to record the change as being done with a different id than the contact that is trying to register (381 vs 374)
  
  Are you sure you are properly anonymous? it might be that your site still think you are "someone else" (eg. the contact you deleted?).
  
  Could you try creating a new account from a "clean" computer, or if you can't, try doing it with your computer, but from an anonymous session (each browser has a different way of doing that, in firefox, it's File->New Private window) and see if you experience the same issue?
  
  and if you do, could you temporarily disable the og\_sync, to try to narrow down where the problem comes from?
  
  X+
  
  > **Comments:**
  > **username_0**: Wohooo!! You are right. I simply took another browser (chrome instead of firefox) and it works again! Strange - since I took firefox's private mode, so I thought cookies cant be the problem... So my paranoia was unjustified.Thanks !  
  
  ---
  
  ### Answer by username_2 on 2016-06-07. Score: 0
  
  Logging out and back in solved the problem for me.
  
  I had deleted a contact (probably associated contact with the logged in user). And then I began seeing this error.
  
  
  ---
  
  