Magento – Products missing from price index after order place

magento-1

There seem to be many issues around the re-indexing of product prices on order placement. See the other issue re deadlocks which is related…
Price re-index causes DB deadlocks during checkout

I have reported this to Magento and they have replied that I should set indexing to Manual so that it is not run. However I don't see how this is a solution.

In addition to deadlocks, we also notice that some products are suddenly missing from the catalog_product_index_price table after being ordered. They are configurable products and they are in stock, however some of their simple products are not.

The problem is products no longer show up on the website if they don't have a record in product price.

How can I prevent this from happening?

Or why does price have to be reindexed at this time?

I don't think this is needed:

8 /var/www/html/app/code/core/Mage/CatalogInventory/Model/Observer.php(689): Mage_Catalog_Model_Resource_Product_Indexer_Price->reindexProductIds(Array)

Best Answer

Reindexing is done for a number of reasons after checkout, here are a few things you can look into:

Percona

Check out the Percona Toolset. We generally use that alongside Percona's build of MySQL. The toolset is a set of diagnostic tools, and there's one just for this. It's called pt-deadlock-logger.

New Relic

We have our clients purchase access to New Relic Pro. When you have it connected, you can easily see all the SQL behind your methods. This helps find ORM calls that might not be efficient and is super convenient when trying to profile and refactor.

Checkout Events

We've seen a ton of crazy stuff observing checkout - it's crazy. I'd look at all of those and see what you can do.

Move Indexers

You could rewrite your indexes to use something other than MySQL. We did this before and it was a dramatic improvement. It was before Magento had the new RDBMS abstraction in 1.6, but is something that would be worth doing.