Hi,

I am receiving following error every time when i do operation like 'edit','delete feed items' for particular 'feed' node.

Plz look into screenshot.

I am using

D-6.16
PHP 5.3.0
CCK 6.x-2.6
Filefield 6.x-3.2
Imagefield 6.x-3.2
Feeds 6.x-1.0-alpha12
Feeds Image Grabber 6.x-1.0-beta1

I am trying to fetch feed from http://feeds.feedburner.com/people/stylewatch/offtherack
and generating feed item with cck images.

Thanks in Advance

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex_b’s picture

Priority: Critical » Normal

Could you describe your feeds importer configuration in detail? (Feel free to do an export and **attach** the export as text file here). Thank you.

Setting this to non-critical as 'critical' is reserved for confirmed bugs with a fix scheduled to go into next release.

kuldip zala’s picture

FileSize
1.77 KB

Export configuration and attached.

alex_b’s picture

Thanks - the configuration is actually looking good. When you install devel module and do a dsm($item), then import - are there URLs and GUIDs present in these items?

enjoyaol’s picture

FileSize
1.42 KB

Hi Alex,

I'm having the same warning when I try to import nodes with the CSV parser.
The nodes are imported (example : Updated 2 Feed item nodes.) but I get this message:
user warning: Duplicate entry 'feed-17' for key 'PRIMARY' query: INSERT INTO feeds_source (id, feed_nid, config, source, batch) VALUES ('feed', 17, 'a:2:{s:16:\"FeedsFileFetcher\";a:2:{s:6:\"source\";s:36:\"sites/default/files/feeds/test_7.csv\";s:6:\"upload\";s:0:\"\";}s:14:\"FeedsCSVParser\";a:1:{s:9:\"delimiter\";s:1:\";\";}}', 'sites/default/files/feeds/test_7.csv', 'b:0;') in C:\xampp\htdocs\ecigcompare\includes\common.inc on line 3477.

And the nodes are not showing in the workspaces nor in the node list.

I 'm attaching my configuration as well. Hope it helps

aquila’s picture

I am experiencing very similar problems, subscribing.

slicedsoup’s picture

Priority: Normal » Critical

yes same problem here

alex_b’s picture

Priority: Critical » Normal

#4 - could you also post a(n anonymized version of) the CSV file you're importing?

cato’s picture

Version: 6.x-1.0-alpha12 » 6.x-1.0-alpha14

I've been hunting this error for a while now since it appears everytime I edit/import the feed.
The solution is to either quit updating the feed_nid field in DB or to remove it from the index.

mysql> show create table feeds_source\G
*************************** 1. row ***************************
       Table: feeds_source
Create Table: CREATE TABLE `feeds_source` (
  `id` varchar(128) NOT NULL DEFAULT '',
  `feed_nid` int(10) unsigned NOT NULL DEFAULT '0',
  `config` text,
  `source` text NOT NULL,
  `batch` longtext,
  PRIMARY KEY (`id`,`feed_nid`),
  KEY `id` (`id`),
  KEY `feed_nid` (`feed_nid`),
  KEY `id_source` (`id`,`source`(128))
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

Looking at the mysql log, it's clear that the db handling code for both Feeds and Feeds Image Grabber creates the same error: It tries to update the (unique) key field in the table(s) for no apparant reason.

10 Query	UPDATE feeds_source SET id = 'feed', feed_nid = 203, config = 'a:1:{s:16:\"FeedsHTTPFetcher\";a:1:{s:6:\"source\";s:107:\"http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/sf=143456/limit=10/xml\";}}', source = 'http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topfreeapplications/sf=143456/limit=10/xml', batch = 'b:0;' WHERE id = 'feed' AND feed_nid = 203

Regards,
Christopher Cato

bropp’s picture

Status: Closed (fixed) » Active

I'm also getting this error when setting up a new feed. After it attempts to import new articles, I get the following errors:

user warning: Duplicate entry 'rss_feed-0' for key 'PRIMARY' query: INSERT INTO feeds_source (id, feed_nid, config, source, batch) VALUES ('rss_feed', 0, 'a:1:{s:16:\"FeedsHTTPFetcher\";a:1:{s:6:\"source\";s:36:\"feed://justjaredjr.buzznet.com/feed/\";}}', 'feed://justjaredjr.buzznet.com/feed/', 'b:0;') in /Applications/MAMP/htdocs/includes/common.inc on line 3477.

Download of feed://justjaredjr.buzznet.com/feed/ failed with code -1003.
rjb’s picture

Status: Needs review » Active

#8 helped me to find the problem. Thanks!

The feeds module contains code like this:

// Make sure a source record is present at all time, try to update first,
// then insert.
drupal_write_record('feeds_source', $object, array('id', 'feed_nid'));
if (!db_affected_rows()) {
  drupal_write_record('feeds_source', $object);

First an update of the object is attempted. Then db_affected_rows() is called to check if the update succeeded. The programmer expected db_affected_rows() to return zero only if the object does not exist in the database. Then the object would be inserted.

However if the object does not differ from the one stored in the database, then db_affected_rows() also returns zero. If you think of it, this seems logical because no update was needed (the data is the same), but it was not expected by the programmer. Now the code will try to insert an already existing object (an object with the same key), causing the warning message to appear.

I'm working on a quick patch.

Cheers,
Ronald

rjb’s picture

Status: Active » Needs review
FileSize
2.47 KB

Here is the patch.
Now a "SELECT COUNT(*)" is used to check if the object already exists. If this is the case, then an UPDATE is performed else an INSERT is done. It works for me, but feel free to comment.

Cheers,
Ronald

batje’s picture

This is indeed throwing errors. Ugly but a (temp) fix is

ALTER TABLE `feeds_source` DROP PRIMARY KEY ,
ADD INDEX `PRIMARYOLD` ( `id` , `feed_nid` )

ChaosD’s picture

iam getting this error, too - no matter what parser and mappign settings i use

subscribed

cato’s picture

#10 Ronald, you're welcome.

alex_b’s picture

Status: Active » Needs review

#10 - thank you. #11 looks like the proper solution. Will review as soon as I get some time. Is #11 addressing the reported problems for everybody here?

ChaosD’s picture

i can confirm that the errors are gone but now iam having trouble with something different. dont know if its releated so i opened a new issue
#810822: HTTP error 404 in import

TimG1’s picture

I'm not getting this error with feeds, but occasionally get it elsewhere with other modules. In my case it's due to MySQL 5.1.

http://www.palantir.net/blog/beware-mysql-51-my-son

Sorry to interrupt, but thought I'd share in case it's helpful/related.

Carry on... =)

-Tim

AlexisWilke’s picture

Hi guys,

I've got a similar problem with menu_per_role as pointed out by one of my users. The problem is the DEFAULT specification on PRIMARY keys. You have that one too. Because of that, the UPDATE will create a row when none are found. Yes, that's an incredible bug since such a row should not be created by an UPDATE statement, but it does...

Btw, thanks TimG1 who gave the answer in the link/post in his issue.

Anyway, I don't use MySQL so I cannot tell you for sure, but look into this:

  $schema['feeds_importer'] = array(
    'description' => 'Configuration of feeds objects.',
    'export' => array(
      'key' => 'id',
      'identifier' => 'feeds_importer',
      'default hook' => 'feeds_importer_default',  // Function hook name.
      'api' => array(
        'owner' => 'feeds',
        'api' => 'feeds_importer_default',  // Base name for api include files.
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'id' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',   // REMOVE THIS!!! WHY PUT AN EMPTY STRING ON A PRIMARY KEY??? (menu_per_role has a 0!)
        'description' => 'Id of the fields object.',
      ),
      'config' => array(
        'type' => 'text',
        'not null' => FALSE,
        'description' => 'Configuration of the feeds object.',
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array('id'),
  );

Thank you.
Alexis Wilke

P.S. Btw, patch in #11 is a very slow work around in comparison! and the feed_update_xxx() should use db_field_set_no_default().

jamielennox’s picture

subscribing

AlexisWilke’s picture

P.S. The DEFAULT is certainly a problem, but the real problem is MySQL. It's broken as of 5.1.<something>. There was a fix applied by Dries a in 2005, but it broke again.

So what I mentioned earlier should be fixed, but that won't make this problem go.

Thank you.
Alexis

smartinm’s picture

The #11 patch actually works fine, but SELECT COUNT(*) do not perform well in InnoDB tables.

I've attached the same patch using db_query_range(), more info in Do not use SELECT COUNT(*) to check for existence of rows in a table.

smartinm’s picture

Patch with small comment typo fix introduced on #21.

alex_b’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

Status: Active » Closed (fixed)