Skip to content

Constraint error on updating event participant fields #78

@scoobird

Description

@scoobird

When running the job using cron manually, I get a constraint violation error from mysql. All contribution records update but the event records do not. When the job runs independently with cron, the contribution records do not update either.

Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`test_civi`.`civicrm_value_summary_fields_55`, CONSTRAINT `FK_civicrm_value_summary_fields_55_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452
Additional Details:
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO `civicrm_value_summary_fields_55` (entity_id, name_of_the_last_attended_event_425,date_of_the_last_attended_event_426,total_number_of_events_427,number_of_events_attended_428) (SELECT contact_id, event_last_attended_name,event_last_attended_date,event_total,event_attended FROM `civicrm_tmp_e_dflt_df4b897eb392f535097ef8a9ddcd79fe`) ON DUPLICATE KEY UPDATE  name_of_the_last_attended_event_425 = event_last_attended_name, date_of_the_last_attended_event_426 = event_last_attended_date, total_number_of_events_427 = event_total, number_of_events_attended_428 = event_attended [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`test_civi`.`civicrm_value_summary_fields_55`, CONSTRAINT `FK_civicrm_value_summary_fields_55_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO `civicrm_value_summary_fields_55` (entity_id, name_of_the_last_attended_event_425,date_of_the_last_attended_event_426,total_number_of_events_427,number_of_events_attended_428) (SELECT contact_id, event_last_attended_name,event_last_attended_date,event_total,event_attended FROM `civicrm_tmp_e_dflt_df4b897eb392f535097ef8a9ddcd79fe`) ON DUPLICATE KEY UPDATE  name_of_the_last_attended_event_425 = event_last_attended_name, date_of_the_last_attended_event_426 = event_last_attended_date, total_number_of_events_427 = event_total, number_of_events_attended_428 = event_attended [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`test_civi`.`civicrm_value_summary_fields_55`, CONSTRAINT `FK_civicrm_value_summary_fields_55_entity_id` FOREIGN KEY (`entity_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_value_summary_fields_55` (entity_id, name_of_the_last_attended_event_425,date_of_the_last_attended_event_426,total_number_of_events_427,number_of_events_attended_428) (SELECT contact_id, event_last_attended_name,event_last_attended_date,event_total,event_attended FROM `civicrm_tmp_e_dflt_df4b897eb392f535097ef8a9ddcd79fe`) ON DUPLICATE KEY UPDATE  name_of_the_last_attended_event_425 = event_last_attended_name, date_of_the_last_attended_event_426 = event_last_attended_date, total_number_of_events_427 = event_total, number_of_events_attended_428 = event_attended [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`test_civi`.`civicrm_value_summary_fields_55`, CONSTRAINT `FK_civicrm_value_summary_fields_55_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]"]
)

Can replicate using latest master, CiviCRM 5.28.2 and mariadb versions 10.3.23 and 10.1.45 as well as on an older version of the client's database, so it doesn't seem like an emerging issue with the data. Any idea where this is coming from or how to continue troubleshooting? Appreciate any assistance here -- Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions