I've got 2 servers. One my local dev server, where clear cache/drush cc all works fine. The other, the "production" server I get this:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'FeedsCSVParser-class' for key 'PRIMARY'

The things that's odd about it is the way I built the production server is by dumping my dev database and restoring it on the server. I've updated a few places to deal with file system differences (e.g. media files), but otherwise everything seems to be working, except that I can't clear my cache. If I delete the feed importer, I can clear the cache. Obviously that's not ideal :)

I've seen other reports of similar errors. It's definitely some sort of bug, but I'm not sure that's it's a) related to Feeds specifically or b) not caused by my database dump/import.

Any pointers/suggestions appreciated.

Thanks.

Colin

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

colin_young’s picture

Just for fun, I tried to clone the importer and delete the problem one, but that didn't help. It seems that just having an importer causes the problem.

pameeela’s picture

I'm having the same problem but with profile2. Locally cc all works fine but on the production server it's throwing:

WD profile2_type: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'main_clone' for key 2: INSERT [error]
INTO {profile_type} (type, label, weight, data, status, module) 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); Array

Several other similar issues mention duplicate include files but I can't find any more detail on this.

colin_young’s picture

It seems that it's definitely a result of moving the files from server to server. Truncating the cache table cleared it up for me (oddly, I excluded that from backup_migrate, but it was still giving me trouble). Thanks to #1324000: Failed to rebuild registry on PDO Exception: duplicate entry for cluing me in.

pameeela’s picture

We solved our problem by upgrading to the stable version of profile2, but it only worked if the change was done before the cache was cleared for the first time - i.e. a fresh install without the dev version of profile2.

Clearing cache with the dev version of profile2 breaks something, and the

PDOException: SQLSTATE23000: Integrity constraint violation: 1062 Duplicate entry 'main_clone'

is present regardless what upgrades are performed.

Possibly truncating the cache table would have worked too but in the meantime we got around it.

juampynr’s picture

This happens because Feed's plugins are being loaded twice (first at feeds.info and then by Ctools).

There is no need in having the list of plugins included in the feeds.info file. Attached is a patch that fixes the issue.

juampynr’s picture

Component: Miscellaneous » Code
Priority: Normal » Critical
Status: Active » Needs review

Changing status.

emackn’s picture

Assigned: Unassigned » emackn

Are there steps to reproduce this error?

juampynr’s picture

Sure, here you are:

  1. Enable Feeds module.
  2. Create a feed.
  3. Save it into a feature.
  4. Clone the whole site (code and db) to another box.
  5. Once the site is ready, clean the cache > an SQL error raises such as the one in the issue description at the top of the page.

I wonder if it is because of the line:

plugins/FeedsPlugin.inc:111:    ctools_include('plugins');

That collides with the lines at feeds.info where it is already including all plugins. The patch I provided above fixes the issue so that proves that there is an attempt to double load plugins while recreating the registry.

emackn’s picture

clearing cache via drush?

The only step i dont do is move the code to a different physical server. I move it to a different database and vhost, but fail to get the error you are talking about. I don't doubt that it is happening, just need to find a reliable way to reproduce the error.

juampynr’s picture

Yes.

drush cache-clear all

It may seem hard to recreate but it is a common scenario when you copy a dev environment to your local box.

twistor’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

@juampy Having the class files in the .info file doesn't mean that they are included. It means that they can be automatically loaded if the class isn't available. The error you're describing would occur regardless of a migration.

juampynr’s picture

@twistor, I just could reproduce it consistently with the steps given at #8.

How could then removing the files from feeds.info fix the error?

emackn’s picture

Im beginning to think these are separate issues. One being the PDO error (which looks fixed), and the other being the unnecessary inclusion of plugins in the feeds info file. I'm going to commit the info file change and close this issue.

emackn’s picture

Status: Needs work » Closed (fixed)

committed at d350c4515cd31dc93cdc42f18e532f4ba1f2ed9f

colin_young’s picture

FWIW and as the original reporter, I think you're right about there being 2 issues here.

I'm not entirely convinced that moving the cache data from one site to another is the right thing to do. It does sound like you've found a legitimate unrelated problem as a result of my report though.

juampynr’s picture

I have found that this same error has been reported in issues form other projects. However there is no clear answer to what the problem exactly is.

#1324000: Failed to rebuild registry on PDO Exception: duplicate entry
#1265564: PDOException due to class auto-loading registry when running a cache clear

twistor’s picture

Status: Closed (fixed) » Active

Removing the classes from the .info is the wrong decision.
There was already an issue to add them in the first place. #1201638: Plugins should be listed in info file.

One thing that should be tried is removing the file and path arguments from feeds.plugins.inc. I know for a fact that this works, but I don't know if it will fix the bug as I can't reproduce it.

@#15, It's the registry that's the tricky part since it stores the actual filename of each class.

How can this be committed on a hunch? There hasn't been a logical reason as to why this approach works, and if it does prove to work, it's still the exact wrong approach and something else needs to be fixed.

juampynr’s picture

Status: Postponed » Active

Here are updated steps to reproduce the problem consistently:

  1. Download Feeds module within a named site at sites directory (ie. sites/drupal7.localhost/modules/contrib/feeds).
  2. Enable Feeds module and create a feed (this should make Ctools load its plugins and save them in cache).
  3. Create a feed.
  4. Clone the whole site (code and db) to another directory and rename sites/drupal7.localhost by sites/drupal7b.localhost.
  5. Clean the cache > The error occurs.

I am debugging includes/registry.inc to see why the file is being loaded twice.

juampynr’s picture

I debugged the Ctools plugin system and found an issue with it. I have created an issue in the Ctools issue queue with a patch that fixes this error (#1371700: CTools adds cached plugins with wrong paths during hook_registry_files_alter() in multisite systems). I need someone to verify that the patch given there fixes the issue. If it does, then it is safe to add the plugins again to feeds.info.

twistor’s picture

Status: Active » Needs review
FileSize
5.06 KB

I've been meaning to submit this anyway, but this patch adds the classes back to the .info file and removes the path and file arguments from feeds.plugins.inc.

I've verified that nothing explodes. Can someone test to see if it solves the issue?

abeger’s picture

There seems to be some work on the root problem here: #1372122: STOP the registry integrity constraint violation nightmare

Matthew Davidson’s picture

I've tried twistor's patch - the feeds.plugin.inc bit of it at least; the .info file bit is redundant if you didn't apply the earlier patch - and I can now flush the cache with no side effects I've been able to detect. However the same issue affects the (broken anyway) D7 port of iCal feed parser and goodness knows how many other modules, so it's good to see the problem getting some attention in core, where it needs to be addressed. I think this should be considered a temporary workaround.

juampynr’s picture

The issue has been explained at http://drupal.org/node/1372122#comment-5392170. There is a suggested core patch that fixes all these issues by doing a db_merge() instead of a db_insert().

Hopefully we can get this moving and solve a set of reported issues.

emackn’s picture

Status: Needs review » Postponed

awaiting outcome of core patch

joseph_leon’s picture

Status: Active » Postponed

I had the same problem as you guys but I fixed it by turning off the feed modules, clearing cache in the drupal admin (not drush), running cron, then turning back on the modules. After that everything worked fine.

juampynr’s picture

Status: Postponed » Fixed

Drupal 7.14 includes a fix for this.

http://drupal.org/node/1558424

Status: Fixed » Closed (fixed)

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

scripthead’s picture

Issue summary: View changes

Still happening on 7.32.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '48768-lbs_user_guide-messages' for key 'PRIMARY': INSERT INTO {ctools_object_cache} (sid, obj, name, data, updated) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => 48768 [:db_insert_placeholder_1] => lbs_user_guide [:db_insert_placeholder_2] => messages [:db_insert_placeholder_3] => a:0:{} [:db_insert_placeholder_4] => 1422324354 ) in ctools_object_cache_set() (line 90 of /storage/www/lbs/sites/all/modules/contrib/ctools/includes/object-cache.inc)