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

milesw’s picture

Ah, great, same problem here. The patch fixes the situation for me, allowing imports to continue on subsequent cron runs. Thanks!

podox’s picture

Status: Needs review » Reviewed & tested by the community

Fixes a long-standing issue for us also. Brilliant - looking forward to seeing this rolled-in. Many thanks.

Chris Charlton’s picture

Found this thread just now, and it seems like good timing. :)

twistor’s picture

Alrighty, I was going to say this needs a test, but it turned out to be a bit subtle.

Let's see if this works.

twistor’s picture

  • Commit 01e5d17 on 7.x-2.x authored by dagomar, committed by twistor:
    Issue #2275893 by twistor, dagomar: Fixed Process in background doesn't...
  • Commit 4ddb9a0 on 7.x-2.x by twistor:
    #2275893 Add tests for import in background.
    
twistor’s picture

Status: Needs review » Fixed

Thanks!

silurius’s picture

Status: Fixed » Needs work

Very 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

silurius’s picture

Oh, 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.

dagomar’s picture

@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.

silurius’s picture

StatusFileSize
new4.69 KB

Here they are.

twistor’s picture

I 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.

silurius’s picture

Thanks 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.

kopeboy’s picture

I 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 :/

kopeboy’s picture

Title: Process in background doesn't work on non-periodic imports » Process for non-periodic imports will get stuck
Priority: Normal » Major
pal4life’s picture

Whats the consensus on this one? I am having a similar issue.
Thanks.

RAWDESK’s picture

Similar 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

RAWDESK’s picture

I 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..

megachriz’s picture

Status: Needs work » Fixed

The 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.

megachriz’s picture

Status: Fixed » Closed (fixed)
Chris Charlton’s picture