I deleted all feeds items for a feed node processor ("items" in my case).
Then re-imported that feed, only to see integrity constraint failures like below.
It looks like the entries in feeds_item table were not deleted? So when it re-imports, it get these failures, because the old data is still there.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'item-21608' for key 'PRIMARY': INSERT INTO {feeds_item} (entity_type, entity_id, id, feed_nid, imported, url, guid, hash) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => item [:db_insert_placeholder_1] => 21608 [:db_insert_placeholder_2] => csv_m4n [:db_insert_placeholder_3] => 9 [:db_insert_placeholder_4] => 1312585065 [:db_insert_placeholder_5] => http://clicks.m4n.nl/_c?aid=21755&adid=667288&_df=true&turl=http%3A%2F%2Fwww.prettyyou.nl%2Fproduct_info.php%3Fproducts_id%3D5978%26utm_source%3Dm4nfeed%26utm_medium%3Dcpc%26utm_campaign%3Dm4n [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => 989a68cb9bda3b28780423163d8201cd ) in drupal_write_record() (line 6859 of C:\Inetpub\wwwroot\shopcircuit.dev\includes\common.inc).

Comments

Anonymous’s picture

I've done a full flush of the entire system, truncated all relevant tables, and this still happens!
As a matter of fact, the feeds_item table remains empty. No data is written.

Anonymous’s picture

Title: Integrity constraint in {feed_items} during import: as if not deleted before? » Integrity constraint in {feed_items} during import: no data written, import fails
Version: 7.x-2.0-alpha4 » 7.x-2.x-dev

Same in dev-x. My feeds-item table is empty... still the above error occurs.

	PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'item-399' for key 'PRIMARY': INSERT INTO {feeds_item}  .....

How is that even possible?

Anonymous’s picture

Priority: Normal » Major

Reverted back to 2.x-alpha3 and the problems are gone. What was changed in alpha4 that causes this? By the way, the Feeds log does not exist at /admin/reports/dblog/feeds, but at admin/reports/feeds.

Anonymous’s picture

Any update? This is kind of critical. The Feeds module simply no longer works, it can't import anything.

Anonymous’s picture

Status: Active » Fixed

After comparing both alpha3-alpha4 versions, I was able to solve it. I was using a custom entity type and custom hooks to run feeds_item_info_insert($entity, $id);

This was missing in alpha3, but you added it to alpha4 - good job!

/**
 * Implements hook_entity_insert().
 */
function feeds_entity_insert($entity, $type) {
  list($id) = entity_extract_ids($type, $entity);
  feeds_item_info_insert($entity, $id);
}

So the solution to my problem was removing my custom feeds_item_* code. It was causing duplicate entry-issues.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

carn1x’s picture

Version: 7.x-2.x-dev » 7.x-2.0-alpha4
Status: Closed (fixed) » Active

Looking at the dates, I assume this issue still lives in alpha4? Is it fixed in Dev?

I'm getting the following error with 7.x-2.0-alpha4

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'commerce_product-62' for key 'PRIMARY'

As above, my feeds_item table is empty.

Anonymous’s picture

Hi, do you still have a custom hook_entity_insert() somewhere? In my case, the duplicate issue was caused by a duplicate implementation of that hook with feeds_item_info_insert($entity, $id); in it.

So I had to remove my custom feeds_item_info_insert($entity, $id);, because that is in alpha4/devx now, so you don't need it yourself anymore.

At least, that was my case.

carn1x’s picture

@morningtime I don't believe so, I've not added such a hook myself, and this specific change was made to Commerce Feeds in the latest dev version. Advice I've been given is to uninstall Feeds in order to kill the related tables and then reinstall, I'll report back :)

erikhopp’s picture

Subscribe. I'm seeing this problem as well. Using alpha4.

AdamGS’s picture

Having a similar problem when a rule is enabled on the event 'After saving new content'. The rule is updating a field on the imported node. I'm get the following error when importing a CSV file:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '132185-3-content_access_rid' for key 'PRIMARY'

is this the same error or do i need to create a new issue?

ditcheva’s picture

Hi everyone,

I'm also seeing this. I had the node feeds working perfectly until I mapped the node id to a an id from my import file. Now I'm not longer able to import any nodes, even when I delete all the current nodes from my site.

It's important to have the ability to maintain node id's however, so simply allowing node id's to change across imports is not a good work-around.

Any updates would be much appreciated! :-)

ditcheva’s picture

UPDATE: I found out why I was getting this error. In my case it was actually coming from apache_solr, which I'm using for my search. The server was not running (because this is a test site I'm using on localhost) and so it was not updating its index data properly.

I can now insert nodes perfectly with the 7.x-2.0-alpha4 version.

bibo’s picture

Also having this error, but disabling apache_solr/search_api doesnt seem to have much effect.
I can import some nodetypes, but not all, which is very annoying.

imiksu’s picture

Is this error valid in 7.x-2.0-alpha5 version?

Ivanhoe123’s picture

Yes. I'm getting this randomly when importing from several sources.

Sometimes it imports all articles, sometimes it imports part and throws an error for the rest.

This is the full error:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '738' for key 'vid'

imiksu’s picture

I had this problem when using my custom rules action. The action basically wrapped the entity with metadata wrapper and then did some changes on entity and after that I saved it within the action callback, which caused this error.

My workaround was to basically loading a fresh copy of the entity with commerce_product_load_multiple(array($product_id), array(), TRUE) where third argument set the $reset to be TRUE.

twistor’s picture

Status: Active » Closed (fixed)

This is not a generic issue from integrity constraint problems. Almost every one of these is a separate issue, from what I can tell. Please open new issues if you're still having this problem.