While working on a D6 -> D8 migration, I noticed that over 90% of the items for the d6_term_node_revision migration were being ignored, which seemed high. Using xdebug to trace the migration, I identified some specific items that were being ignored that I was pretty sure should be valid. I believe the issue is with the process specification in d6_term_node_revision.yml:

process:
  vid:
    -
      plugin: migration_lookup
      migration: d6_node
      source: vid
    -
      plugin: skip_on_empty
      method: row

It's trying to translate the node revision ID (which doesn't actually need translating (but might in the future)) as a means of ensuring that items for which the node doesn't exist are skipped (https://www.drupal.org/project/drupal/issues/2588945). However, it's specifying d6_node, meaning it looks in migrate_map_d6_node_[content_type], which maps node IDs, not revision IDs. Hence why about 6% of the items, in my case, are getting through - those are the ones that are lucky and happen to have a revision ID that's also a valid node ID.

I thought I could just change the migration parameter for migration_lookup in the above code to d6_node_revision, but that results in all items being ignored (because the migration plugin manager is finding no instances for that migration ID in migration lookup's transform function), so I seem to still be missing a piece of the puzzle.

Comments

Olarin created an issue. See original summary.

olarin’s picture

Version: 8.4.x-dev » 8.5.x-dev
Issue summary: View changes
StatusFileSize
new489 bytes

Aha! Changing it to look to d6_node_revision for the migration_lookup does indeed work; there's just a corresponding change that also needs to be made in the Migrate Upgrade module, in case you're using the contrib modules to try all this from the command line via drush (which of course you are because how else can you reasonably try migrations one at a time), to make sure it remembers to have the derivative d6_node_revision migration IDs on hand to sift through.

Here's a patch for this issue. Will be submitting corresponding patch to Migrate Upgrade momentarily.

olarin’s picture

Status: Active » Needs review
olarin’s picture

olarin’s picture

Patch for 8.4.x. Actually differs slightly because the file location has changed between versions (directory was renamed).

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

olarin’s picture

A patch for 8.6.x, identical to the patch for 8.5.x, just proving it still applies.

heddn’s picture

Assigned: Unassigned » heddn

Assigning to myself to review. This does seem like a major issue. So leaving the priority.

dww’s picture

Agreed this is a major (if not critical) bug in the D6 term migration. I just saw this last night on a D6 migration I'm working on. Seeing this issue totally explains what happened. Here's the output of trying to run my term_node and term_node_revision migrations:

 [notice] Processed 12597 items (12597 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:1'
 [notice] Processed 14156 items (14156 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:2'
 [notice] Processed 445 items (445 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:4'
 [notice] Processed 1059 items (1059 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:5'
 [notice] Processed 13792 items (13792 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:6'
 [notice] Processed 13271 items (13271 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:7'
 [notice] Processed 23632 items (23632 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:8'
 [notice] Processed 11940 items (11940 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:9'
 [notice] Processed 8558 items (8558 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:10'
 [notice] Processed 1224 items (1224 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:18'
 [notice] Processed 380 items (380 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:12'
 [notice] Processed 1576 items (1576 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:13'
 [notice] Processed 17728 items (17728 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:14'
 [notice] Processed 17724 items (17724 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:15'
 [notice] Processed 3727 items (3727 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:16'
 [notice] Processed 6635 items (6635 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node:17'
 [notice] Processed 24930 items (112 created, 0 updated, 0 failed, 24818 ignored) - done with 'd6_term_node_revision:1'
 [notice] Processed 25297 items (113 created, 0 updated, 0 failed, 25184 ignored) - done with 'd6_term_node_revision:2'
 [notice] Processed 1036 items (6 created, 0 updated, 0 failed, 1030 ignored) - done with 'd6_term_node_revision:4'
 [notice] Processed 56 items (14 created, 0 updated, 0 failed, 42 ignored) - done with 'd6_term_node_revision:5'
 [notice] Processed 9106 items (26 created, 0 updated, 0 failed, 9080 ignored) - done with 'd6_term_node_revision:6'
 [notice] Processed 9610 items (30 created, 0 updated, 0 failed, 9580 ignored) - done with 'd6_term_node_revision:7'
 [notice] Processed 20198 items (82 created, 0 updated, 0 failed, 20116 ignored) - done with 'd6_term_node_revision:8'
 [notice] Processed 23364 items (93 created, 0 updated, 0 failed, 23271 ignored) - done with 'd6_term_node_revision:9'
 [notice] Processed 21582 items (64 created, 0 updated, 0 failed, 21518 ignored) - done with 'd6_term_node_revision:10'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node_revision:18'
 [notice] Processed 741 items (6 created, 0 updated, 0 failed, 735 ignored) - done with 'd6_term_node_revision:12'
 [notice] Processed 378 items (1 created, 0 updated, 0 failed, 377 ignored) - done with 'd6_term_node_revision:13'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node_revision:14'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node_revision:15'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node_revision:16'
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'd6_term_node_revision:17'

The term_node output is all as expected, but the numbers are totally off from reality for term_node_revision*.

I'll be re-running the migration this afternoon with the equivalent fixes from @Olarin to both the migration .yml files and migrate_upgrade. Stay tuned for the results, but I suspect they'll be much more promising.

Thanks!
-Derek

heddn’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This is a pretty obvious break/fix. However, we should probably add a test for this.

heddn’s picture

Assigned: heddn » Unassigned
heddn’s picture

Status: Needs work » Reviewed & tested by the community

I'm the one who originally put this back to NW. This is obviously a broken thing. Let's just fix it. I am not sure there is much value in a test.

dww’s picture

In general, +1 to the RTBC, although the migration where I saw this ended up not caring about migrating revisions. But, I did try it once and it worked. It's such an obvious fix.

Thanks,
-Derek

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I think we should have some test coverage of this. Since if we reverted the fix no test would fail.

olarin’s picture

I haven't had time to circle back to this and write any tests yet. While I'm a proponent of maintaining good test coverage, I wonder if, for a bug this egregious and a fix this obvious, it wouldn't be acceptable to go ahead and commit the fix and open up a followup issue for adding test coverage if deemed necessary. Of course there's a substantial risk that the followup issue will fall to the back of the queue and get ignored, but that still seems better to me than the fix not getting committed for months on end, given that right now node revision migrations are almost completely broken and have been for a long time.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

maxocub’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.19 KB
new2.66 KB

I investigated this and I found that the current tests pass because the revision ID used in the migration_lookup is never absent from the d6_node mapping table so no rows are ever skipped.

One way to make a failing patch can be to change this low revision ID to one high enough so that it's not found in the d6_node mapping table and thus the row will be skipped.

But with the fix applies, this new high revision ID will be found in the d6_node_revision mapping table and thus the row will be migrated.

The test only-patch is the interdiff.

There might be some other test failures due to the fact that I changed a revision ID. Let's see how it goes.

The last submitted patch, 17: 2934799-17-test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 17: 2934799-17.patch, failed testing. View results

maxocub’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB
new3.25 KB
new3.73 KB

Fixed the failing test.

The last submitted patch, 20: 2934799-20-test-only.patch, failed testing. View results

heddn’s picture

Status: Needs review » Reviewed & tested by the community

And now, with the tests, we can go back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Backported to 8.6.x as this is a major bug fix that improves migrations.

Committed and pushed d4eb909c23 to 8.7.x and abd11edbd0 to 8.6.x. Thanks!

  • alexpott committed d4eb909 on 8.7.x
    Issue #2934799 by maxocub, Olarin, heddn, dww: d6_term_node_revision...

  • alexpott committed abd11ed on 8.6.x
    Issue #2934799 by maxocub, Olarin, heddn, dww: d6_term_node_revision...

Status: Fixed » Closed (fixed)

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