Page MenuHomePhabricator

DB-locking query, possibly related to merge
Closed, DeclinedPublic

Description

@LeanneS was trying to merge two contact records, and it wasn't working. This SQL was running for half an hour before we killed it

INSERT IGNORE INTO civicrm_temp_civireport_logsummary SELECT entity_log_civireport.id as log_civicrm_entity_id, 1, entity_log_civireport.log_action as log_civicrm_entity_log_action, 'log_civicrm_contact' as log_civicrm_entity_log_type, entity_log_civireport.log_user_id as log_civicrm_entity_log_user_id, entity_log_civireport.log_date as log_civicrm_entity_log_date, modified_contact_civireport.display_name as log_civicrm_entity_altered_contact, modified_contact_civireport.id as log_civicrm_entity_altered_contact_id, entity_log_civireport.log_conn_id as log_civicrm_entity_log_conn_id, modified_contact_civireport.is_deleted as log_civicrm_entity_is_deleted, altered_by_contact_civireport.display_name as altered_by_contact_display_name  
FROM `civicrm`.log_civicrm_contact entity_log_civireport

INNER JOIN civicrm_contact modified_contact_civireport
        ON (entity_log_civireport.id = modified_contact_civireport.id )
LEFT  JOIN civicrm_contact altered_by_contact_civireport
        ON (entity_log_civireport.log_user_id = altered_by_contact_civireport.id) WHERE ( 1 )  AND (entity_log_civireport.log_action != 'Initialization') GROUP BY entity_log_civireport.log_conn_id, entity_log_civireport.log_user_id, EXTRACT(DAY_MICROSECOND FROM entity_log_civireport.log_date), entity_log_civireport.id  ORDER BY entity_log_civireport.log_date DESC

Event Timeline

This query is consistent with looking at the change log report - its the report that shows on a contacts Change Log tab - but there doesn't seem to be a contact id filter - I think the merge @LeanneS mentioned is a red herring - ie the merge was a VICTIM of the above query which was kicked off 30 mins earlier

Note that this report is also available in the civi reports menu so it might be possible just to cause this by choosing to 'see what that report does' - we don't discourage that exploring but perhaps we should remove this report from the menu

Doesn't seem to be recurring much