Problem/Motivation
For a feed with 'Process in background' set, but with no periodic import set, the import will get stuck and never finish. On investigation it turns out that at first a job is scheduled, importing the first part. When that is done no new job is scheduled, thus resulting in an unfinished 'locked' job.
Proposed resolution
I traced the problem down to the method scheduleImport() in includes/FeedsSource.inc. At line 299 I believe the condition is too loose and does not take into account that a job may actually still be ongoing. I changed that line from:
if ($period == FEEDS_SCHEDULE_NEVER) {
to
if ($period == FEEDS_SCHEDULE_NEVER && $this->progressImporting() === FEEDS_BATCH_COMPLETE) {
and things started to work as expected. Basically there is an extra check, it won't remove the task if the feed isn't completely imported yet. This seems to have solved my problem.
I will attach a patch.
Comments
Comment #1
milesw commentedAh, great, same problem here. The patch fixes the situation for me, allowing imports to continue on subsequent cron runs. Thanks!
Comment #2
podox commentedFixes a long-standing issue for us also. Brilliant - looking forward to seeing this rolled-in. Many thanks.
Comment #3
Chris CharltonFound this thread just now, and it seems like good timing. :)
Comment #4
twistor commentedAlrighty, I was going to say this needs a test, but it turned out to be a bit subtle.
Let's see if this works.
Comment #6
twistor commented4: feeds-process-in-background-without-periodic-import-fix-2275893-4-should-fail.patch queued for re-testing.
Comment #8
twistor commentedI had un-pushed commits.
Let's try this again.
Comment #11
twistor commentedThanks!
Comment #12
silurius commentedVery sorry for changing the status, but I am still experiencing this issue even after upgrading to the June 12 7.x-2.x-dev. Details:
1. "Skip hash check" is unchecked, "Periodic import" is set to Off, "Process in background" is checked
2. Imported 64 records
3. Import page seemed to stop at 76%
4. Unlock page shows the 76% status
5. Ran cron manually (/admin/reports/status/run-cron)
6. All records were successfully imported, but each record was imported in duplicate or triplicate
7. Unlock page still shows the 76% status
Log:
2014-06-12 13:56:27 2014-06-12 13:55:10 Created 64 nodes.
2014-06-12 13:56:27 2014-06-12 13:55:10 Imported in 27 s
2014-06-12 13:55:59 2014-06-12 13:55:10 Created 64 nodes.
2014-06-12 13:55:59 2014-06-12 13:55:10 Imported in 93 s
Comment #13
silurius commentedOh, and this may not be related, but when I unchecked "Process in background" and imported 580 nodes, the import was a 100% success (no duplicates) but this warning appeared:
Notice: Undefined index: start_time in FeedsSource->import() (line 406 of /my-path/sites/all/modules/feeds/includes/FeedsSource.inc). Figured I should mention this, since that file was patched today.Comment #14
dagomar commented@silurius
I'd be willing to have a look if you supply an export of your feed and the source you're trying to import.
Comment #15
silurius commentedHere they are.
Comment #16
twistor commentedI just tested out your configuration and it works as expected.
Can you try it on a clean install? It's possible there's something else messing things up. Also, try re-downloading the dev release. It sometimes takes them a while to get created and yours could be old.
Comment #17
silurius commentedThanks for trying to reproduce the problem with my export. I'll upgrade Feeds to the latest dev release and then retest on Monday. Won't have an opportunity to create a fresh Drupal install for another few weeks if not longer, due to irons in the fire.
Comment #18
kopeboyI am having a similar problem with "Import on submission", no schedules.
I always get this error:
An AJAX HTTP error occurred. HTTP Result Code: 504 Debugging information follows. Path: /en/batch?id=6473&op=do StatusText: Target not responding.in the middle of the process (I don't know why, it might be memory related, cause I'm importing nodes with many images).
The import will be stuck at xx%.
Running cron, flushing caches doesn't work.
I have to unlock, and restart the import (with the uploaded file), which will get another error :/
Comment #19
kopeboyComment #20
pal4life commentedWhats the consensus on this one? I am having a similar issue.
Thanks.
Comment #23
RAWDESK commentedSimilar issue here, but solved itself after manually running cron.
I've written a programmatically driven commerce product ref -> product feed using this guide :
http://drupal.stackexchange.com/questions/90062/programmatically-execute...
Both feeds are executed in sequence (first prd ref, then prd) with these settings :
- use standalone form
- periodic import off
- process in background unchecked
- Update existing commerce products selected
- Skip hash check unchecked
Running :
- Commerce Feeds 7.x-1.4
- Feeds 7.x-2.0-beta1
- Feeds tamper 7.x-1.1
Comment #24
RAWDESK commentedI was apparently already running on a Feeds_source.inc version which included the patch.
Did somebody committed this patch to Feeds 7.x-2.0-beta1 ?
Side note : My second import suffered from the same stalling symptom. Maybe because it had to do (more cpu consuming?) update tasks on existing nodes.. Running cron manually didn't reengaged the pending import this time..
Comment #25
megachrizThe original reported issue seems to have been fixed, so marking this issue as fixed. There can be other causes why an import does not complete on cron. See #1995728: [META] Cron import not working on 7.x-2.0-alpha8 and later.
Comment #26
megachrizComment #27
Chris Charlton