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 »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Duplicate Key Error - No Duplicate
Pages: [1]

Author Topic: Duplicate Key Error - No Duplicate  (Read 2257 times)

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Duplicate Key Error - No Duplicate
February 26, 2011, 12:41:11 pm
I have a problem on my test sever that doesn't appear on my live server, but it is keeping me from developing a couple of new things for a client.

When I fill out a membership form and submit it, I get the following error:

Code: [Select]
Additional Details:

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

    [code] => -5
    [message] => DB Error: already exists
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  3641 , 'you@there.net' ,  6430 )  [nativecode=1062 ** Duplicate entry 'you@there.net-1' for key 'UI_uf_name_domain_id']
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  3641 , 'you@there.net' ,  6430 )  [nativecode=1062 ** Duplicate entry 'you@there.net-1' for key 'UI_uf_name_domain_id']
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_uf_match (domain_id , uf_id , uf_name , contact_id ) VALUES ( 1 ,  3641 , 'you@there.net' ,  6430 )  [nativecode=1062 ** Duplicate entry 'you@there.net-1' for key 'UI_uf_name_domain_id']"]
)

Going thru the forum, I see that this is usually caused by duplicate emails in the system. In my case there are no duplicates in the uf_match table. I can copy the SQL statement and paste it into phpMyAdmin and it executes without error. I have also tried with wacky email addresses that I know aren't in the system (i.e. blargh@shanana.net) and still have the issue.

Here is what I have tried:
  • Empty uf_match table and re-sync.
  • Dump entire db and reload from mysql commandline to force rebuilding of indexes
  • Step through code and look for the possibility that the code that creates the uf_match record is running 2x
  • cleared civicrm cache, drupal cache, browser cache, session cookies to be sure no cached data was interfering with process
Is there anything I missed? Has anyone else been stuck with something similar?

Thanks for your help,
Q
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Duplicate Key Error - No Duplicate
February 27, 2011, 09:40:15 am

hmm

seems like u should get the same error in PMA. Can you double/triple check that you are using the same DB as civi when accessing via PMA

enable mysql logs and see if that code is being called twice (and queries are being repeated). however even if called twice and failing second time, your PMA queries should also fail

if no progress made, get on IRC and we can try to help out

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Duplicate Key Error - No Duplicate
March 01, 2011, 07:17:27 am
OK lobo,

After your help yesterday, I did enable the civicrm query logging with backtrace and found that the query was being issued twice. I don't know why that wasn't showing in the mysql log, but at least something made sense.

I enabled logging on the live site for just a couple of minutes and ran through the same process and checked the log. No uf_match insert query was being issued. I couldn't figure out why there was a difference, but I decided to just tear down my dev server and rebuild with a backup of the code and data from the live site.

I still don't know what happened, but the rebuild appears to have solved my problem. If it happens again I will probably try to trace the problem to its source, but for now I am going to thank $diety that I can get the project back on track :)
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

dpolant

  • I’m new here
  • *
  • Posts: 7
  • Karma: 1
Re: Duplicate Key Error - No Duplicate
March 18, 2011, 12:20:44 pm
I'm having this exact same issue. I'm interested in figuring out why this happens.

The bizarre thing I noticed is that in my uf_match table, there's a bunch of entries that have a 0 for uf_id (drupal id that is). I bet if I run the sync again it will fix it, but I'd prefer to spend a bit of time to try and understand why this is happening and possibly fix a bug.

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Duplicate Key Error - No Duplicate
March 21, 2011, 08:31:26 am
I'm having the same error.

It happens on a new registration ahead of paying (it's fine if they select to pay later). There's no duplicate email in the uf_match table so am guessing queries are being repeated.

This is what backtrace prints out on the error page:

Code: [Select]
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php, backtrace, 159
, handle,
/home/-site-/administrator/components/com_civicrm/civicrm/packages/PEAR.php, call_user_func, 931
/home/-site-/administrator/components/com_civicrm/civicrm/packages/DB.php, PEAR_Error, 968
/home/-site-/administrator/components/com_civicrm/civicrm/packages/PEAR.php, DB_Error, 564
/home/-site-/administrator/components/com_civicrm/civicrm/packages/DB/common.php, raiseError, 1903
/home/-site-/administrator/components/com_civicrm/civicrm/packages/DB/mysql.php, raiseError, 898
/home/-site-/administrator/components/com_civicrm/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
/home/-site-/administrator/components/com_civicrm/civicrm/packages/DB/common.php, simpleQuery, 1216
/home/-site-/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php, query, 2421
/home/-site-/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php, _query, 1053
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php, insert, 281
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/BAO/CMSUser.php, save, 150
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Contribute/BAO/Contribution/Utils.php, create, 371
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, createCMSUser, 994
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Contribute/BAO/Contribution/Utils.php, processContribution, 114
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php, processConfirm, 1034
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, postProcessMembership, 583
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php, postProcess, 250
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/StateMachine.php, mainProcess, 167
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 64
/home/-site-/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/home/-site-/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php, handle, 284
/home/-site-/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php, run, 219
/home/-site-/components/com_civicrm/civicrm.php, invoke, 81
/home/-site-/components/com_civicrm/civicrm.php, civicrm_invoke, 24
/home/-site-/libraries/joomla/application/component/helper.php, require_once, 162
/home/-site-/includes/application.php, renderComponent, 124
/home/-site-/index.php, dispatch, 68

Thanks for your help

Nic

edit - this probably didn't happen after upgrading to 3.3.5 from 3.3.3 as I've found a transaction that went thru fine since then.
« Last Edit: March 21, 2011, 10:05:41 am by nicol »

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Duplicate Key Error - No Duplicate
March 21, 2011, 08:54:55 am
I don't know why this happens, but I can describe what is happening based on what I tracked down.

For some reason 2 queries are being generated to create a uf_match record. A number of queries are wrapped together in a transaction to ensure data integrity. Since there is a duplicate FK detected on the second uf_match insert, the whole transaction is rolled back. That is why you never actually see the records in the table - they never make it.

I still don't know why this happened, and I think it will take someone with a little more internal CiviCRM knowledge than I have to track it down.
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Duplicate Key Error - No Duplicate
March 21, 2011, 10:04:40 am
Thanks. Unfortunately my skills aren't up to knowing what to do next.

Re-reading this, my error is perhaps slightly different - it isn't titled 'duplicate key error' but 'Sorry. A non-recoverable error has occurred. DB Error: already exists' yet the error code, mode and description is just the same as yours.

Also when I click submit it does create a row in civicirm_uf_match and send out email notifications. But still the error, presumably as there is a second query as you say.

I wonder if it could be linked to the payment processor as it doesn't happen if the membership is set to 'pay later'. I'm using Paypal standard.

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Duplicate Key Error - No Duplicate
March 21, 2011, 03:39:07 pm
My mistake, it was this bug - http://issues.civicrm.org/jira/browse/CRM-5330

There'd been a dozen spam registrations overnight and I'd deleted them in user manager. The jos_user and civicrm_uf_match table didn't have them in but something must have been stored somewhere as all the new attempted signups would use the same record and id in the uf_match table.

I've deleted corresponding records in civicrm_contact, cos_user, jos_acl_aro, jos_acl_groups_aro_map + uf_match back to the last genuine signup.

Not sure if a similar bug exists in Drupal - otherwise, apologies for invading your thread! (and only searching the forum, not the tracker).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Duplicate Key Error - No Duplicate

This forum was archived on 2017-11-26.