Problem

I was attempting to go through a limited migrate-import to debug it. The migration shows over 800 records in it. The first step works fine:

$ drush mi menumigration --limit=100
Processed 100 items (100 created, 0 updated, 0 failed, 0 ignored) - done with 'menumigration' 

Trying to run the migration again with a limit only imports a single record:

$ drush mi menumigration --limit=100
Processed 1 item (1 created, 0 updated, 0 failed, 0 ignored) - done with 'menumigration'

This occurs whether or not the limit is changed in subsequent runs. Running the migrate-import with no limit will complete the migration correctly. I originally found the issue on 8.x-2.0-beta1 but it is still present on 8.x-2.x-dev.

Proposed resolution

Issue is that the limit is not factoring in the records already processed. I'll be attaching a patch shortly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dhansen created an issue. See original summary.

dhansen’s picture

Status: Active » Needs review
FileSize
686 bytes
draenen’s picture

Patch applies and works for me.

mikeryan’s picture

Status: Needs review » Needs work

Actually, that's not ideal. The basic problem is that prepareRow gets called for already-imported items, so the counter is not reflecting what's actually been "processed". And I'm not sure in all cases prepareRow will always be called for all previously-imported items first. I'm thinking the itemLimit code should be using getProcessedCount() rather than $this->counter.

dhansen’s picture

@mikeryan I'm a little unclear about your comment as the patch already adds the use of getProcessedCount(). Is there somewhere else in the code this needs to be altered?

dman’s picture

I've been getting this and it's been killing me for three days - I blamed all the weird and wonderful things I've been doing to my own imports. I could have sworn it used to work as advertised last month when I did my proof-of-concepts for my current job - but I've been blaming myself for messing something major up, and have been going down to db dump diffs and step-debugging to try and find out what I did wrong.

It's a relief (and also somewhat exhausting) to find out *it's not just me*! Auuuugh!
(migrate_tools 8.2.0-beta-1)

dman’s picture

Additionally, the observation that "prepareRow gets called for already-imported items" goes a loooong way towards explaining my other issue that lost me most of last week - it seemed that the process was incrementally slowing down massively as my runs progressed ... because I thought that I could avoid scaling issues by running repeated batches of nodes (out of 60,000) - processing 1,000 at a time. But the slowdown looked like a memory leak or something. And I spent days trying to isolate *that*.

Patch appears to solve my current problem today, thanks. I'm lost in trying to imagine the "real" solution though. I had imagined there was a high-water-mark or an iterator pointer remembered somewhere, but my investigations so far have not been able to find it.

  • mikeryan committed 372d1e5 on 8.x-2.x
    Issue #2730081 by dhansen,mikeryan: Drush migrate-import limit does not...
mikeryan’s picture

Status: Needs work » Fixed

Fixed by making use of getProcessedCount() in onPrepareRow(), thanks!

  • mikeryan committed 372d1e5 on 8.x-3.x
    Issue #2730081 by dhansen,mikeryan: Drush migrate-import limit does not...

Status: Fixed » Closed (fixed)

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