magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Async order grid indexing setting can't be enabled in production mode (store config / MSI) #36070

Open bst-biwac opened 2 years ago

bst-biwac commented 2 years ago

Preconditions and environment

Steps to reproduce

  1. enable production mode (and MSI)
  2. go to store config
  3. try to enable async order grid indexing under Stores > Settings > Configuration > Advanced > Developer > Grid Settings > Asynchronous indexing as described in Devdocs

Expected result

The config option for async order grid indexing should be visible in production mode

Background: the reason stated for this config option in Devdocs is

There can be times when intensive sales on a storefront occur at the same time that Commerce is performing intensive order processing.

It makes no sense for this config option to be visible in developer mode only. There are no intensive sales in developer mode. However, there are intensive sales in production mode.

Actual result

The config option for async order grid indexing is not visible in production mode

Additional information

We have database deadlocks with sales_order_grid table because we can't enable async order grid indexing in store config

Stack trace

SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: INSERT INTOsales_order_grid(entity_id,status,store_id,store_name,customer_id,base_grand_total,base_total_paid,grand_total,total_paid,increment_id,base_currency_code,order_currency_code,shipping_name,billing_name,created_at,updated_at,billing_address,shipping_address,shipping_information,customer_email,customer_group,subtotal,shipping_and_handling,customer_name,payment_method,total_refunded,pickup_location_code,mailchimp_flag) SELECT sales_order.entity_id ASentity_id, sales_order.status ASstatus, sales_order.store_id ASstore_id, sales_order.store_name ASstore_name, sales_order.customer_id AScustomer_id, sales_order.base_grand_total ASbase_grand_total, sales_order.base_total_paid ASbase_total_paid, sales_order.grand_total ASgrand_total, sales_order.total_paid AStotal_paid, sales_order.increment_id ASincrement_id, sales_order.base_currency_code ASbase_currency_code, sales_order.order_currency_code ASorder_currency_code, TRIM(CONCAT_WS(' ', IF(sales_shipping_address.firstname<> '',sales_shipping_address.firstname, NULL), IF(sales_shipping_address.lastname<> '',sales_shipping_address.lastname, NULL))) ASshipping_name, TRIM(CONCAT_WS(' ', IF(sales_billing_address.firstname<> '',sales_billing_address.firstname, NULL), IF(sales_billing_address.lastname<> '',sales_billing_address.lastname, NULL))) ASbilling_name, sales_order.created_at AScreated_at, sales_order.updated_at ASupdated_at, TRIM(CONCAT_WS(',', IF(sales_billing_address.company<> '',sales_billing_address.company, NULL), IF(sales_billing_address.street<> '',sales_billing_address.street, NULL), IF(sales_billing_address.city<> '',sales_billing_address.city, NULL), IF(sales_billing_address.region<> '',sales_billing_address.region, NULL), IF(sales_billing_address.postcode<> '',sales_billing_address.postcode, NULL))) ASbilling_address, TRIM(CONCAT_WS(',', IF(sales_shipping_address.company<> '',sales_shipping_address.company, NULL), IF(sales_shipping_address.street<> '',sales_shipping_address.street, NULL), IF(sales_shipping_address.city<> '',sales_shipping_address.city, NULL), IF(sales_shipping_address.region<> '',sales_shipping_address.region, NULL), IF(sales_shipping_address.postcode<> '',sales_shipping_address.postcode, NULL))) ASshipping_address, sales_order.shipping_description ASshipping_information, sales_order.customer_email AScustomer_email, sales_order.customer_group_id AScustomer_group, sales_order.base_subtotal ASsubtotal, sales_order.base_shipping_amount ASshipping_and_handling, TRIM(CONCAT_WS(' ', IF(sales_order.customer_firstname<> '',sales_order.customer_firstname, NULL), IF(sales_order.customer_lastname<> '',sales_order.customer_lastname, NULL))) AScustomer_name, sales_order_payment.method ASpayment_method, sales_order.total_refunded AStotal_refunded, inventory_pickup_location_order.pickup_location_code ASpickup_location_code, sales_order.mailchimp_flag ASmailchimp_flagFROMsales_order LEFT JOINsales_order_addressASsales_shipping_addressON sales_order.shipping_address_id = sales_shipping_address.entity_id LEFT JOINsales_order_addressASsales_billing_addressON sales_order.billing_address_id = sales_billing_address.entity_id LEFT JOINsales_order_paymentON sales_order.entity_id = sales_order_payment.parent_id LEFT JOINinventory_pickup_location_orderON sales_order.entity_id = inventory_pickup_location_order.order_id WHERE (sales_order.entity_id = '23370') ON DUPLICATE KEY UPDATEentity_id= VALUES(entity_id),status= VALUES(status),store_id= VALUES(store_id),store_name= VALUES(store_name),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),shipping_name= VALUES(shipping_name),billing_name= VALUES(billing_name),created_at= VALUES(created_at),updated_at= VALUES(updated_at),billing_address= VALUES(billing_address),shipping_address= VALUES(shipping_address),shipping_information= VALUES(shipping_information),customer_email= VALUES(customer_email),customer_group= VALUES(customer_group),subtotal= VALUES(subtotal),shipping_and_handling= VALUES(shipping_and_handling),customer_name= VALUES(customer_name),payment_method= VALUES(payment_method),total_refunded= VALUES(total_refunded),pickup_location_code= VALUES(pickup_location_code),mailchimp_flag= VALUES(mailchimp_flag`) [] []

0 /var/www/webroot/ROOT/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(627): Magento\Framework\DB\Adapter\Pdo\Mysql->_query()

1 /var/www/webroot/ROOT/vendor/magento/module-sales/Model/ResourceModel/Grid.php(109): Magento\Framework\DB\Adapter\Pdo\Mysql->query()

2 /var/www/webroot/ROOT/vendor/magento/module-sales/Observer/GridSyncInsertObserver.php(64): Magento\Sales\Model\ResourceModel\Grid->refresh()

3 /var/www/webroot/ROOT/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Sales\Observer\GridSyncInsertObserver->execute()

4 /var/www/webroot/ROOT/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()

5 /var/www/webroot/ROOT/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()

6 /var/www/webroot/ROOT/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()

7 /var/www/webroot/ROOT/vendor/magento/framework/Model/ResourceModel/Db/VersionControl/RelationComposite.php(53): Magento\Framework\Event\Manager\Proxy->dispatch()

8 /var/www/webroot/ROOT/vendor/magento/framework/Model/ResourceModel/Db/VersionControl/AbstractDb.php(57): Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite->processRelations()

9 /var/www/webroot/ROOT/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(424): Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb->processAfterSaves()

10 /var/www/webroot/ROOT/vendor/magento/module-sales/Model/ResourceModel/Order.php(180): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save()

11 /var/www/webroot/ROOT/generated/code/Magento/Sales/Model/ResourceModel/Order/Interceptor.php(32): Magento\Sales\Model\ResourceModel\Order->save()

12 /var/www/webroot/ROOT/vendor/magento/module-sales/Model/OrderRepository.php(282): Magento\Sales\Model\ResourceModel\Order\Interceptor->save()

...`

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @bst-biwac. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

hostep commented 2 years ago

This one should work: bin/magento config:set dev/grid/async_indexing 1

All config settings can be changed in this way, so even if they don't show up in the backoffice because of production mode.

m2-assistant[bot] commented 2 years ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 2 years ago

Verified the behavior on Magento 2.4-develop and "Developer" configuration is not available when mode set to Production. For other modes: Default and Developer modes - "Asynchronous indexing" config option is available in Grid settings. As per Magento devdocs, the developer tab is available only in developer mode. Hence we are considering this as feature request but not a bug as its an existing behavior of Magento.

sandy6666 commented 2 years ago

This one should work: bin/magento config:set dev/grid/async_indexing 1

All config settings can be changed in this way, so even if they don't show up in the backoffice because of production mode.

This is the current valid solution.