2

I have a few pairs of contacts for which merging fails with an immediate 503 page. For these contacts, merging always fails, while for almost all contacts, it works as expected.

A couple errors are being logged, can post the other ("We can't load the requested web page. This page requires cookies to be enabled in your browser settings...") if needed, but this seems like the most relevant. 5.28.2 on Drupal.

There is nothing special about these contacts, as far as I can tell. Anyone have any ideas what's happening?

    [error] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -5
    [message] => DB Error: already exists
    [mode] => 16
    [debug_info] => UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 34632 [nativecode=1062 ** Duplicate entry '23836-32644' for key 'UI_contact_id1_contact_id2']
    [type] => DB_Error
    [user_info] => UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 34632 [nativecode=1062 ** Duplicate entry '23836-32644' for key 'UI_contact_id1_contact_id2']
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 34632 [nativecode=1062 ** Duplicate entry '23836-32644' for key 'UI_contact_id1_contact_id2']"]
)

 [debug] $backTrace = #0 /var/www/html/sites/all/modules/civicrm/CRM/Core/Error.php(205): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
#2 /var/www/html/sites/all/modules/civicrm/packages/DB.php(997): PEAR_Error->__construct("DB Error: already exists", -5, 16, (Array:2), "UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...")
#3 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-5, 16, (Array:2), "UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...")
#4 /var/www/html/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -5, 16, (Array:2), "UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...", "DB_Error", TRUE)
#5 /var/www/html/sites/all/modules/civicrm/packages/DB/common.php(1925): PEAR->__call("raiseError", (Array:7))
#6 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(936): DB_common->raiseError(-5, NULL, NULL, "UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...", "1062 ** Duplicate entry '23836-32644' for key 'UI_contact_id1_contact_id2'")
#7 /var/www/html/sites/all/modules/civicrm/packages/DB/mysqli.php(406): DB_mysqli->mysqliRaiseError()
#8 /var/www/html/sites/all/modules/civicrm/packages/DB/common.php(1231): DB_mysqli->simpleQuery("UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...")
#9 /var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php(2696): DB_common->query("UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...")
#10 /var/www/html/sites/all/modules/civicrm/packages/DB/DataObject.php(1829): DB_DataObject->_query("UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...")
#11 /var/www/html/sites/all/modules/civicrm/CRM/Core/DAO.php(439): DB_DataObject->query("UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...")
#12 /var/www/html/sites/all/modules/civicrm/CRM/Core/DAO.php(1528): CRM_Core_DAO->query("UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...", TRUE)
#13 /var/www/html/sites/all/modules/civicrm/CRM/Dedupe/Merger.php(588): CRM_Core_DAO::executeQuery("UPDATE civicrm_dedupe_exception SET contact_id2 = 32644 WHERE contact_id2 = 3...", (Array:0), TRUE, NULL, TRUE)
#14 /var/www/html/sites/all/modules/civicrm/CRM/Dedupe/Merger.php(1344): CRM_Dedupe_Merger::moveContactBelongings(Object(CRM_Dedupe_MergeHandler), (Array:6), (Array:0))
#15 /var/www/html/sites/all/modules/civicrm/CRM/Contact/Form/Merge.php(308): CRM_Dedupe_Merger::moveAllBelongings(32644, 34632, (Array:27))
#16 /var/www/html/sites/all/modules/civicrm/CRM/Core/Form.php(504): CRM_Contact_Form_Merge->postProcess()
#17 /var/www/html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Submit.php(58): CRM_Core_Form->mainProcess()
#18 /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Submit->perform(Object(CRM_Contact_Form_Merge), "submit")
#19 /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Contact_Form_Merge), "submit")
#20 /var/www/html/sites/all/modules/civicrm/CRM/Core/Controller.php(347): HTML_QuickForm_Page->handle("submit")
#21 /var/www/html/sites/all/modules/civicrm/CRM/Utils/Wrapper.php(98): CRM_Core_Controller->run()
#22 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(285): CRM_Utils_Wrapper->run("CRM_Contact_Form_Merge", "Merge Contact", (Array:0))
#23 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(68): CRM_Core_Invoke::runItem((Array:13))
#24 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:3))
#25 /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module(454): CRM_Core_Invoke::invoke((Array:3))
#26 /var/www/html/includes/menu.inc(527): civicrm_invoke("contact", "merge")
#27 /var/www/html/index.php(21): menu_execute_active_handler()
#28 {main}
1

This was a core bug reported at https://lab.civicrm.org/dev/core/-/issues/1964 and the fix is available at https://github.com/civicrm/civicrm-core/pull/18223/files

0

I believe what is happening here is that there are two contacts (B is being merged into A), both of which have a dedupe exception set for another contact (C). So the dedupe exceptions table contain records for A-C and B-C.

When the merge is processed, CiviCRM is attempting to update the B-C exception to A-C (because B is being merged into A, the former B-C exception is being replaced with an A-C exception). The A-C exception already exists, hence the error and the merge failure.

Removing the A-C and B-C dedupe exceptions allows the merge of B into A to proceed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.