Calling Developers!
We are reenergizing our code contribution process! Learn More

sync:data doesn't work in an edge case

Options
mikko.ropanen
mikko.ropanen Spryker Solution Partner Posts: 17 🧑🏻‍🚀 - Cadet

If getSynchronizationDataQueryExpanderStrategyPlugin() returns the "WhereBetween" plugin as it does in spryker-suite:

https://github.com/spryker-shop/suite/blob/3733f7c0cd479a4649ad8878176130c3d00fcba2/src/Pyz/Zed/Synchronization/SynchronizationDependencyProvider.php#L185

and the auto-increment id in spy_product_abstract_page_search and/or spy_product_concrete_page_search doesn't start from zero (or technically between 0 and chunk size), then sync:data product_abstract and sync:data product_concrete fail to query data from those tables.

The reason being that their iterators start by querying the tables like:
SELECT FROM `spy_product_abstract_page_search` WHERE id_product_abstract_page_search BETWEEN 0 AND 100 ORDER BY `spy_product_abstract_page_search`.`id_product_abstract_page_search` ASC

and obviously if the first id is 101 or 46249, the query returns nothing → iterator stops → nothing gets synced.

Changing the plugin to SynchronizationDataQueryExpanderOffsetLimitStrategyPlugin seems to work.

Comments

  • ynnoig
    ynnoig Technical Lead eBusiness Spryker Customer Posts: 12 ✨ - Novice
    Options

    To avoid this problem u have to implement the Interface \Spryker\Zed\SynchronizationExtension\Dependency\Plugin\SynchronizationDataMaxIterationLimitPluginInterface and implement the method getMaxIterationLimit . In this case the iteration is stopped at first the max iteration limit is reached.

    The specification of this interface say:
    The Iterator can proceed until maxIterationLimit is reached even if intermittent result sets are empty.