I have Magento 2.4.1 with MariaDB and a catalogue of 370,000 products. I’m trying to delete source items through the REST API. It used to work well in the past, but today I can’t get it to work. Even deleting a single source item results in an error.
Using the endpoint /V1/inventory/source-items-delete
with PyMagento:
>>> client.delete_source_items([{'sku': 'mysku', 'source_code': 'mysource'}])
...
magento.exceptions.MagentoException: Internal Error. Details are available in Magento log file. Report ID: webapi-63ff1c22cac22
If I grep for this report ID in the log, I get:
Next Exception: Report ID: webapi-63ff1c22cac22; Message: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction, query was: RENAME TABLE inventory_stock_2 TO inventory_stock_2_outdated,inventory_stock_2_replica TO inventory_stock_2,inventory_stock_2_outdated TO inventory_stock_2_replica in /home/bixoto_admin/ecom/vendor/magento/framework/Webapi/ErrorProcessor.php:208
Why does Magento try to rename an entire table just to delete a single source item?