Skip to content

Failure to allocate memory error when importing customers in admin #8851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kevin-carroll-cl opened this issue Mar 10, 2017 · 8 comments
Closed
Labels
bug report Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@kevin-carroll-cl
Copy link

kevin-carroll-cl commented Mar 10, 2017

When importing customers into a site with a large number of existing customers through the standard Magento importer tool (System > Data Transfer > Import), with Entity Type: Customers Main File, and Import Behavior: Add/Update Complex Data, the import POST returns a 500 status caused by exceeding allowed memory limits.

Preconditions

  1. Magento Enterprise 2.1.4
  2. Server is running PHP version 7.0.15
  3. Memory limit is set to the standard 768 MB
  4. The target store already has a large number of customers (eg 250k+, we experience it at 261,659)

Steps to reproduce

  1. In admin, go to SYSTEM > Import
  2. Set Entity Type to: Customers Main File
  3. Set Import Behavior to: Add/Update Complex Data
  4. Select a valid import CSV with at least 1 customer row, and select Check Data
  5. After data validates, select Import

Expected result

  1. Customer data should be imported

Actual result

  1. Import Screen loader never expires & Import POST responds with status code 500:
  2. Server error log shows a corresponding PHP Fatal error:

PHP Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 20480 bytes) in /server/sites/(SITE)/vendor/magento/framework/Model/ResourceModel/Db/VersionControl/Snapshot.php on line 47, referer: https://(SITE)/backend/admin/import/
ImportError.txt

The memory use appears to be mainly triggered by framework level code (\Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::registerSnapshot), and is likely platform independent.

Through profiling and debugging we have found 2 very expensive processes that seem to be contributing to this. When beginning the customer import, \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage::getCustomerId is called, which triggers \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage::load to execute which in turn executes \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIterator::iterate. Through this process every existing customer account is retrieved and loaded, which is a costly procedure to begin with, but then the email, website id and customer ids are loaded into a multidimensional array. Additionally, loading the customer array as part of the CollectByPagesIterator::iterate method, triggers snapshotting every customer and loading the whole entity data into another in memory array.

Every existing customer is loaded and initialized as a full customer entity object, and data is held in multiple in-memory locations, in order to import a relatively small collection of new customers. This is an unsustainable practice, is costly in time, processing, and memory, and it is difficult to see the value in doing this.

@sopedro
Copy link

sopedro commented Apr 8, 2017

Hi, same issue here in CE 2.1.5.
I imported a lot of products with no problems and i tried to import customers and i just can import 3 customers at a time.

This is weird, no log results at all, I don't know how to fix it...

Thanks,

Pedro

@IlnitskiyArtem
Copy link

@kevin-carroll-cl , Thanks for the feedback.
Unfortunately, I could not reproduce the issue in 2.1.5 , 2.1.7, 2.1-develop, 2.2.0(develop) with file in attachment (change file extensions from '.txt' to '.csv').
May please let me know if this issue relevant for latest release of Magento 2? And if you can, attach your import file.
CustomersMainFile.txt

@adriansavuosf
Copy link

Hi,

We have the same problem as described in the ticket by kevin-carroll-cl . In order to reproduce it you need to have a store that already have inside a lot of customer (our import doesn't work after 100k users and memory limitation of 256 MB). When you are trying to import new customers after a specific number of customers are already imported, you will not be able to import even 1 more customer.

@IlnitskiyArtem
Copy link

@kevin-carroll-cl Internal ticket MAGETWO-70964, which tracks this GitHub issue, is in our issue backlog.

@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed and removed Progress: needs update labels Sep 18, 2017
@magento-engcom-team
Copy link
Contributor

@kevin-carroll-cl, thank you for your report.
We've created internal ticket(s) MAGETWO-70964 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Sep 22, 2017
@MattDelac
Copy link

Hi @sopedro

Did you find any work around ?

Thanks
Matt

@MattDelac
Copy link

As a similar problem, if I import 100 customers, it works but it fails with more than 150 clients (for a total database of 2K existing clients)

An there is NO information concerning the failure
selection_473

Does someone have any idea of how can I resolve this problem ?

Thank you in advances
Matt

@piotrekkaminski
Copy link
Contributor

This issue was moved to magento-engcom/import-export-improvements#43

magento-devops-reposync-svc pushed a commit that referenced this issue Mar 27, 2024
…-21-2024

[Support Tier-4-Kings glo28218] 03.21.2024 Regular delivery of bugfixes and improvements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

9 participants