magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

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

Open bst-biwac opened this issue 2 years ago • 5 comments

Preconditions and environment

  • Magento version: latest
  • Production mode
  • MSI enabled

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 INTO sales_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 AS entity_id, sales_order.status AS status, sales_order.store_id AS store_id, sales_order.store_name AS store_name, sales_order.customer_id AS customer_id, sales_order.base_grand_total AS base_grand_total, sales_order.base_total_paid AS base_total_paid, sales_order.grand_total AS grand_total, sales_order.total_paid AS total_paid, sales_order.increment_id AS increment_id, sales_order.base_currency_code AS base_currency_code, sales_order.order_currency_code AS order_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))) AS shipping_name, TRIM(CONCAT_WS(' ', IF(sales_billing_address.firstname<> '',sales_billing_address.firstname, NULL), IF(sales_billing_address.lastname<> '',sales_billing_address.lastname, NULL))) AS billing_name, sales_order.created_at AS created_at, sales_order.updated_at AS updated_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))) AS billing_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))) AS shipping_address, sales_order.shipping_description AS shipping_information, sales_order.customer_email AS customer_email, sales_order.customer_group_id AS customer_group, sales_order.base_subtotal AS subtotal, sales_order.base_shipping_amount AS shipping_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))) AS customer_name, sales_order_payment.method AS payment_method, sales_order.total_refunded AS total_refunded, inventory_pickup_location_order.pickup_location_code AS pickup_location_code, sales_order.mailchimp_flag AS mailchimp_flagFROMsales_orderLEFT 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

  • [X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

bst-biwac avatar Sep 01 '22 14:09 bst-biwac

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

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

: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

m2-assistant[bot] avatar Sep 01 '22 14:09 m2-assistant[bot]

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.

hostep avatar Sep 01 '22 19:09 hostep

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:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Sep 05 '22 11:09 m2-assistant[bot]

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.

engcom-November avatar Sep 20 '22 04:09 engcom-November

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.

sandy6666 avatar Sep 20 '22 12:09 sandy6666