Problem/Motivation

In all versions since commit 86a140f (issue 2403593) my migrations are broken.

I'm migrating 27990 terms (MySQL database -> MySQL Drupal database), and the migration stops before all items are processed.
I've tried both the import immediately through UI, import in background through cli drush.

It appears that in each run, half of all items are processed (first run 27990 -> 14000 processed, 2: 7000, 3: 3990 (leaves 4000), 4: 2000, 5: 1000)

I hope this is enough info to get a bell ringing with someone :)

CommentFileSizeAuthor
#6 migration_doesn_t-2415597-6.patch2 KBmikeryan

Comments

thijsvdanker’s picture

Issue summary: View changes
thijsvdanker’s picture

thijsvdanker’s picture

Issue summary: View changes
mikeryan’s picture

*Sigh*. That buffering may be more trouble than it's worth...

I'll see if I can reproduce and debug this. Thanks for reporting it, I'd hate to get 2.7 out and then have to do a 2.8 right away...

mikeryan’s picture

Oh, I see it - the premise of the LIMIT clause is that each time we execute the query, the base query (without the LIMIT) returns exactly the same set of rows in the same order. However, if we're joining with the map table, which we're populating as we go, then each batch of 2000 rows the base query is 2000 rows shorter. So, on our second batch we're expecting to get rows 2001-4000, but since rows 1-2000 have been eliminated from the base query, the rows we want to fetch are now rows 1-2000 and we skip them.

This will take a bit of thought - how do we prevent this situation without reintroducing the previous problem? At a deeper level, I'm not sure we really want to trust the premise - if migrating from a live database where more rows might be added during the migration process, things are going to get messed up. It might be best to give up on the batching for now, or at least make it optional (documented with plenty of caveats about scenarios like this).

mikeryan’s picture

Assigned: Unassigned » mikeryan
Status: Active » Needs review
StatusFileSize
new2 KB

OK, the attached patch makes batching of the query optional (by defaulting batch_size to 0 and taking that to mean no batching), as well as setting map_joinable FALSE when batching is used. I've also added documentation at https://www.drupal.org/node/1152150#batch_size.

mikeryan’s picture

Issue tags: +Migrate 2.7
thijsvdanker’s picture

Solved my issue! can't judge if the code is right.. So it's at least "tested by the community" :)

mikeryan’s picture

Status: Needs review » Fixed

Great, committed, thanks!

  • mikeryan committed a12258e on 7.x-2.x
    Issue #2415597 by mikeryan: Make batching of SQL sources optional, and...

Status: Fixed » Closed (fixed)

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