CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)
Pages: [1]

Author Topic: constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)  (Read 1632 times)

scurra71

  • I’m new here
  • *
  • Posts: 18
  • Karma: 1
  • CiviCRM version: 3.3.3
  • CMS version: Drupal 6.19
  • MySQL version: 5.0.51a
  • PHP version: 5.2.4-2ubuntu5.14
constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)
August 04, 2010, 01:06:44 am
Hi

I have just run the "sites/all/modules/civicrm/bin/UpdateMembershipRecord.php" for the first time. Now, when I view Drupal user details (/users/<username>), I get the following error:


Code: [Select]
Sorry. A non-recoverable error has occurred.

DB Error: constraint violation


Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`drupalsaoga/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452


Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_acl_cache (contact_id , acl_id ) VALUES ( 102 ,  2 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`drupalsaoga/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_acl_cache (contact_id , acl_id ) VALUES ( 102 ,  2 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`drupalsaoga/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_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_acl_cache (contact_id , acl_id ) VALUES ( 102 ,  2 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`drupalsaoga/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]"]
)

I am using the following versions:

PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2
Drupal 6.16
CiviCRM 3.1.4

What's the best way to resolve this?

[/code]
« Last Edit: August 04, 2010, 01:08:36 am by scurra71 »

scurra71

  • I’m new here
  • *
  • Posts: 18
  • Karma: 1
  • CiviCRM version: 3.3.3
  • CMS version: Drupal 6.19
  • MySQL version: 5.0.51a
  • PHP version: 5.2.4-2ubuntu5.14
Re: constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)
August 04, 2010, 01:18:09 am
Some database info:

Code: [Select]
mysql> select count(*) from civicrm_acl_cache;
+----------+
| count(*) |
+----------+
|       32 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from civicrm_contact;
+----------+
| count(*) |
+----------+
|     1945 |
+----------+
1 row in set (0.00 sec)

mysql> select count(*) from civicrm_acl;
+----------+
| count(*) |
+----------+
|       61 |
+----------+
1 row in set (0.00 sec)

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)
August 04, 2010, 01:28:40 am
Can empty following tables and check if that helps:
civicrm_acl_cache
civicrm_acl_contact_cache
civicrm_cache

Hth
Kurund
Found this reply helpful? Support CiviCRM

scurra71

  • I’m new here
  • *
  • Posts: 18
  • Karma: 1
  • CiviCRM version: 3.3.3
  • CMS version: Drupal 6.19
  • MySQL version: 5.0.51a
  • PHP version: 5.2.4-2ubuntu5.14
Re: constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)
August 04, 2010, 01:37:05 am
Thanks! That worked. Much obliged.

I should have Googled before I posted. I see now this has come up before.

(http://forum.civicrm.org/index.php?topic=14560.0)

Thanks again!

ehowland

  • I’m new here
  • *
  • Posts: 25
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: various
  • PHP version: various
Re: constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)
December 02, 2010, 03:39:35 pm
I got this from a multisite drupal install (separate everything) in which I was temporarily pointing to a different sites CiviCRM database.  What worked for me was truncating the drupal sessions table as suggested in this thread:

http://forum.civicrm.org/index.php?topic=15788.0

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • constraint violation (civicrm_acl_cache, FK_civicrm_acl_cache_contact_id)

This forum was archived on 2017-11-26.