2016-09-23 223 views
1

我有一个很少扩展的magento站点。主扩展程序是唯一代码的giftcard扩展。我们现在正在使用800K代码进行升级,因此它创造了巨大的流量。问题是现在它正在创造幽灵订单作为付款后 - 在订单必须从预订订单注册到确认的最后一刻 - 它显示表锁定错误。magento超出锁定等待超时sales_flat_order_grid

精确的错误是:

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction, query was: INSERT INTO sales_flat_order_grid (entity_id , status , store_id , customer_id , base_grand_total , base_total_paid , grand_total , total_paid , increment_id , base_currency_code , order_currency_code , store_name , created_at , updated_at , billing_name , shipping_name) SELECT main_table . entity_id , main_table . status , main_table . store_id , main_table . customer_id , main_table . base_grand_total , main_table . base_total_paid , main_table . grand_total , main_table . total_paid , main_table . increment_id , main_table . base_currency_code , main_table . order_currency_code , main_table . store_name , main_table . created_at , main_table . updated_at , CONCAT(IFNULL(table_billing_name.firstname, ''), ' ', IFNULL(table_billing_name.middlename, ''), ' ', IFNULL(table_billing_name.lastname, '')) AS billing_name , CONCAT(IFNULL(table_shipping_name.firstname, ''), ' ', IFNULL(table_shipping_name.middlename, ''), ' ', IFNULL(table_shipping_name.lastname, '')) AS shipping_name FROM sales_flat_order AS main_table LEFT JOIN sales_flat_order_address AS table_billing_name ON main_table . billing_address_id = table_billing_name . entity_id LEFT JOIN sales_flat_order_address AS table_shipping_name ON main_table . shipping_address_id = table_shipping_name . entity_id WHERE (main_table.entity_id IN('140650')) ON DUPLICATE KEY UPDATE entity_id = VALUES(entity_id), status = VALUES(status), store_id = VALUES(store_id), customer_id = VALUES(customer_id), base_grand_total = VALUES(base_grand_total), base_total_paid = VALUES(base_total_paid), grand_total = VALUES(grand_total), total_paid = VALUES(total_paid), increment_id = VALUES(increment_id), base_currency_code = VALUES(base_currency_code), order_currency_code = VALUES(order_currency_code), store_name = VALUES(store_name), created_at = VALUES(created_at), updated_at = VALUES(updated_at), billing_name = VALUES(billing_name), shipping_name = VALUES(shipping_name)

似乎有效,但没有提到:对于sales_flat_order_grid实体ID 140650。

如果任何人有任何想法,请让我知道可能的解决方案。

回答

0

好的,我正在回答我自己的问题 - 以防其他人发现有帮助。

解决方案:用main_table.entity_id NOT IN (select sales_flat_order.entity_id from sales_flat_order)更换140650,这将解决它运行插入查询失踪sales_flat_orderentity_id,上面的查询运行。这是因为两个表共享相同的entity_id值。

我也来了解请设置慢查询日志,因为您可以看到哪些查询需要很长时间(他们是创建死锁,因为数据库服务器资源被占用) - 很快我发现这样并解决了第三方扩展慢查询问题 - 没有表锁的错误。

1

此问题可能与早期版本的Magento中的错误有关。它曾经是INSERT into sales_flat_order_grid发生在一个事务中。由于Magento用来填充它的查询,查询规划器无法确定要锁定哪个行,因此锁定了整个sales_flat_order_grid表。而且因为这发生在一个事务中,所以锁被保留到COMMIT。

如果这是导致您的问题的原因,则需要解决将订单网格计算移至commit_after。

+0

如何将代码移至commit_after? 我无法找到订单在网格中保存订单数据的代码。 –

相关问题