2016-09-23 236 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? 我無法找到訂單在網格中保存訂單數據的代碼。 –

相關問題