Problem/Motivation

Drupal 7 to Drupal 11 migration runs forever, seems like it's stuck in an infinite loop. Uninstalling media_migration solves the issue, but of course then no media is migrated ;)

In Drupal 10 it was working fine with the same setup. Not yet clear, what and why things go wrong. Might also be unrelated to Drupal 11 and just be a newer MariaDB version? Any ideas?

Steps to reproduce

Proposed resolution

Remaining tasks

API changes

CommentFileSizeAuthor
#15 3494209-14.patch815 bytesgrevil
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

anybody created an issue. See original summary.

grevil’s picture

Ok, the reason for the infinite loop resides somewhere inside onPrepareRow() in /src/EventSubscriber/MediaMigrationSubscriber.php. Both running drush migrate-import --group=my_migration_group --continue-on-failure and drush migrate-upgrade --legacy-db-key=migrate --configure-only led to the infinite loop.

We tried deleting all migration ymls that were either provided or dependent on media_migration with no avail. After running the migration with minimal migration ymls in config the infinite loop still occured. Once we commented out the "onPrepareRow()" method call in the "MediaMigrationSubscriber" the migration started / the migration was configured successfully.

grevil’s picture

We will take a deeper look soon.

grevil’s picture

Priority: Major » Critical

We found the issue!

This is caused by compatibility code for a core issue:

    // @todo remove when https://drupal.org/i/3164520 is fixed.
    $process = [
      [
        'plugin' => 'media_migration_delta_sort',
        'source' => $field_name,
      ],
    ];

https://drupal.org/i/3164520 was already merged in 9.x, so no idea, why it suddenly causes an infinite loop in 11.x, but nevertheless, this should be fixed.

grevil changed the visibility of the branch 3494209-drupal-7-to-with-d11-compatibility to hidden.

grevil’s picture

grevil’s picture

Status: Active » Needs review

But this can already get reviewed.

grevil’s picture

Priority: Critical » Major

Setting back to major, as the module isn't d11 compatible yet anyway.

EDIT: Although this might happen in d10 as well.

anybody’s picture

Pinged @heddn in #3431903: Automated Drupal 11 compatibility fixes for media_migration. Thank you for finding this! I think we might want to merge this with the D11 compatibility issue or commit this one first.

grevil’s picture

Status: Needs review » Needs work

Bug is back on the table...

anybody’s picture

Let's try with #3209706: Optimize SQL queries additionally. Perhaps we have a crazy case...? (While this page is relatively small!)

grevil’s picture

Ok for some reason, the added array_map changes from https://git.drupalcode.org/project/drupal/-/merge_requests/1797/diffs?fi... in core migrate results in this issue. If we revert getMigrationDependencies() to how it was in D9: https://git.drupalcode.org/project/drupal/-/blob/9.5.x/core/modules/migr... drush migrate-import --group=my_migration_group --continue-on-failure won't be stuck in an endless loop.

I have no idea, how this module affects that line of code. I already commented out all code inside MigratePluginAlterer and in the module file. But it is still stuck in that endless loop, unless I comment out this modules MediaMigrationSubscriber "onPrepareRow" method.

grevil’s picture

#3209706: Optimize SQL queries doesn't solve anything unfortunately.

grevil’s picture

StatusFileSize
new815 bytes

Dirty core patch for the time being.

@Anybody and I will have a deeper look tomorrow.

grevil’s picture

grevil’s picture

Ok, to summarize this. The current MR has nothing to do with the problem and won't fix it.

I successfully migrated all the media to D11:

After applying "3494209-14.patch", I ran into #2797505: Migrations fail due to missing dependency when dependency has skipped rows by the source plugin, because with the patch applied, the dependencies seem to not get resolved correctly anymore. So I manually removed the failing dependencies. After that, a MigrateException was thrown in `/src/EventSubscriber/MediaMigrationSubscriber.php`, line 256.

I simply added a return statement above and everything worked as expected:

    if (empty($final_source_field_name[0]['field_name'])) {
      return;
      throw new MigrateException(
        sprintf(
          "Cannot identify the the media entity's source field name"
        )
      );
    }

This is quite dirty, but everything seems to got migrated just fine! Of course we should find the real cause of this endeavour.

grevil changed the visibility of the branch 3494209-drupal-7-to to hidden.

grevil’s picture

OK, to quickly summarize my actions here:

NONE of the issue branches properly fix this problem!!!

I did a "successful" migration to D11 using the following patches:
Media Migration Patches:

Drupal core Patches:

This is definitely not the proper way to do this, but it seems to do the job just fine. The real cause of this issue still needs to be found.