Problem/Motivation

Marking a row needs-update has no effect if mapJoinable() = FALSE and Highwater Marks is ON.

To reproduce:

1. Create a migration with highwater marks ON and a Drupal\migrate\Plugin\migrate\source\SqlBase source that is not mapJoinable (eg. a D7 database).
2. Run the migration to completion.
3. Mark one or more records in the map table as needs-update (source_row_status=1).
4. Run the migration again and watch as zero records are updated.

Proposed resolution

Modify Drupal\migrate\Plugin\migrate\source\SqlBase::initializeIterator() such that if any records in the map table are marked NEEDS_UPDATE, highwater marks optimization is not added to the query.

As an example, the same fix was applied to D7's migrate module:
Issue: #2379289: migrate-import --update does not seem to work as expected, if map is not joinable, due to highwater field?
Commit: https://cgit.drupalcode.org/migrate/commit/?id=6f2981b

Remaining tasks

Patch, test(s), review.

Comments

chrisolof created an issue. See original summary.

sylvainm’s picture

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

I wrote this patch, inspired by the one in d7 migrate.

Tomorrow, i'll try to add a test

sylvainm’s picture

Forgotten the file…

DeFr’s picture

This should use getRowsNeedingUpdate() on the id map instead of doing a query directly.

sylvainm’s picture

StatusFileSize
new2.33 KB

Thx

sylvainm’s picture

Well, here is a test.

Status: Needs review » Needs work
DeFr’s picture

I think it'd be nice to have a test that only sets some of the node as needing updates instead of all of them, and checking that only those that should be updated are actually updated even though the high water condition isn't added to the query.

Namely, it'd be good to have:

  • an item that's below the high water mark and source_row_status = STATUS_NEEDS_UPDATE (should be updated)
  • an item that's below the high water mark and source_row_status = STATUS_IMPORTED (should be left alone)
  • an item that's above the high water mark and source_row_status = STATUS_IMPORTED (should be updated)

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2859314: Highwater condition with unjoined maps skips unprocessed and NEEDS_UPDATE rows

Closing this as a duplicate of #2859314: Highwater condition with unjoined maps skips unprocessed and NEEDS_UPDATE rows. I'll move credit over there.