elgentos / LargeConfigProducts

Large Configurable Products workaround for Magento 2
91 stars 28 forks source link

Race conditions with price indexer #40

Closed peterjaap closed 5 years ago

peterjaap commented 5 years ago

We noticed some race conditions when saving products; the prewarmer would prewarm immediately after saving a product, while the price indexer for example would still have to return, causing the wrong (old) prices to appear on the frontend.

In order to make the prewarm dependent on the indexers, we introduced an indexer with subscriptions on the relevant tables. When the tables are updated (i.e. through of one the other indexers), the elgentos_lcp_prewarm_cl table is populated. The cron job indexer_update_all_views would then run through the cron and fill the message queue table which the consumer will then pick up to prewarm the updated products.

This will eliminate all race condition problems we've seen in the past. Doing a full reindex (i.e. php bin/magento ind:rei elgentos_lcp_prewarm will prewarm all configurable products.

See version 0.3.0 here; https://github.com/elgentos/LargeConfigProducts/releases/tag/0.3.0

peterjaap commented 5 years ago

NOTE: please make sure you set all the indexers (including this new one) to Update on Schedule, otherwise this will not work / work only partly.

peterjaap commented 5 years ago

Bonus; for those using our magerun2 addons, you can now use a magerun2 command to prewarm specific products in addition to php bin/magento lcp:prewarm;

magerun2 index:reindex-partial elgentos_lcp_prewarm 123 456 789