Cron run fails to import feed on cron run and gives this message

* warning: pg_query() [function.pg-query]: Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list in /var/www/sparcsnew/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT DISTINCT nid FROM feedapi WHERE checked <= 1240863940 AND skip = 0 ORDER BY checked LIMIT 100 OFFSET 0 in /var/www/sparcsnew/sites/all/modules/feedapi/feedapi.module on line 683.

Comments

spydmobile’s picture

note this does not happen during a manual refresh of the feed.

spydmobile’s picture

ok, I am seeing other errors that may be related:



    * warning: pg_query() [function.pg-query]: Query failed: ERROR: column "feedapi.vid" must appear in the GROUP BY clause or be used in an aggregate function in /var/www/sparcsnew/includes/database.pgsql.inc on line 139.
    * user warning: query: SELECT vid FROM feedapi WHERE nid = 178 GROUP BY nid HAVING vid = MAX(vid) in /var/www/sparcsnew/sites/all/modules/feedapi/feedapi.module on line 903.
    * warning: pg_query() [function.pg-query]: Query failed: ERROR: duplicate key value violates unique constraint "feedapi_pkey" in /var/www/sparcsnew/includes/database.pgsql.inc on line 139.
    * user warning: query: INSERT INTO feedapi ( nid, vid, url, link, feed_type, processors, parsers, checked, settings) VALUES (178, 187, 'http://216.108.146.20:7777/wxrss.php', 'http://sm53-fed0218/wxrss/', 'XML feed', 'a:1:{i:0;s:12:"feedapi_node";}', 'a:1:{i:0;s:16:"parser_simplepie";}', 0, 'a:0:{}') in /var/www/sparcsnew/sites/all/modules/feedapi/feedapi.module on line 870.


spydmobile’s picture

the last bit was upon saving the feed after editiing it.

spydmobile’s picture

ok, so I found some of the problems for postgres syntax.
line 903 of feedapi.module is:

$old_vid = db_result(db_query("SELECT vid FROM {feedapi} WHERE nid = %d GROUP BY nid HAVING vid = MAX(vid)", $node->nid));

but should read:

$old_vid = db_result(db_query("SELECT vid FROM {feedapi} WHERE nid = %d GROUP BY nid,vid HAVING vid = MAX(vid)", $node->nid));

because:

column "feedapi.vid" must appear in the GROUP BY clause or be used in an aggregate function

line 683 says:

$result = db_query_range("SELECT DISTINCT nid FROM {feedapi} WHERE checked <= %d AND skip = 0 ORDER BY checked", $start, 0, FEEDAPI_CRON_FEEDS);

but should say

$result = db_query_range("SELECT DISTINCT nid,checked FROM {feedapi} WHERE checked <= %d AND skip = 0 ORDER BY checked", $start, 0, FEEDAPI_CRON_FEEDS);

becuase:

SELECT DISTINCT, ORDER BY expressions must appear in select list

this should solve my problems with cron not running the feed update.
I will come back and confirm when I know.
Franco

spydmobile’s picture

Status: Needs review » Active

Ok, this solved all evident errors, but cron still does not refresh the feed :-(
[EDIT] See next message, its fixed, it just takes a while.

spydmobile’s picture

Status: Active » Needs review

Ok, the above two lines of code seems to have solved the problem, it just takes way longer than I thought.
The RSS feed is produced on demand on the source, but the data changes every hour, and feedapi is not getting the nodes until 20 minutes past the hour,
line 15 of feedapi.module is configured as 60 seconds:

define('FEEDAPI_CRON_MIN_REFRESH_TIME', 60);

so technically it should be able to get the feed every 61 seconds.

Cron occurs every 5 minutes.

the feed node itself is configured with:


Refresh feed on creation is OFF
Update existing feed items is OFF
Pause automatic feed update is OFF
Parser SimplePie
Cache lifetime in seconds: 30

So I cannot explain why my nodes dont show up until 20 minutes after the hour. BUT THEY DO SHOW UP. so the lines above do fix the syntax problem.

spydmobile’s picture

Status: Active » Needs review

Ok, I am bewildered, but after doing nothing, over a few hours the system seems to have fixed itself - My nodes arraived at 10 minutes after this time, exactly when I expected them to. So I am content and need no further resolution except to get my changes rolled into the next dev.
Franco

spydmobile’s picture

Status: Needs review » Fixed

Tested, Fixed in dev of apr 30-2009
works! - thanks, sorry for the confusion!!!!

spydmobile’s picture

Status: Fixed » Needs work

Argh, sorry, this is still an issue in the latest dev! Line numbers have changed but code is stil wrong.

alex_b’s picture

Status: Needs work » Active

Anyone of the postgres people up for a patch?

spydmobile’s picture

Hi alex, I am not sure if you are asking me to make a patch, which I honestly dont know how to do at this point, or if you are asking If I want you to make a patch, which I cant really use, but if you wish to do a dev release I can do that. Sorry if I am not being much help here....
Franco

alex_b’s picture

#11: spydmobile: I'm asking anybody who's using postgres and FeedAPI if they want to roll a patch for this :-)

aron novak’s picture

Status: Active » Fixed

All of the problematic queries were fixed.

Status: Fixed » Closed (fixed)

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