Skip to content

Upgrade to Magento 2.2.4 - Magento_Sales UpgradeData.php - Memory Limit Exceeded / MySQL server has gone away #169

Closed
@adammprost

Description

@adammprost

Issue
When upgrading from 2.2.3 EE to 2.2.4 EE on a site with 4GB of existing data, running bin/magento setup:upgrade fails during the Magento_Sales UpgradeData.php script's fillQuoteAddressIdInSalesOrderAddress() method.

  • Allowed memory size of X exceeded is thrown with a memory_limit of 2GB
  • Increasing the memory_limit to 4GB allows the method to run for about 20 minutes until MySQL has gone away is thrown.

The problem is that the way the fillQuoteAddressIdInSalesOrderAddress() method is constructed it's looping through a fair amount of sales_order_address records (~600,000 in our case) and loading both the order and quote objects on every iteration. That consumes a lot of memory.

Solution
Rather than looping and loading full objects, the update should be done with a single query. See my suggestion here ->
module-sales-upgrade-performance-refactor.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions