Coder Social home page Coder Social logo

Drush entity:delete command (EntityCommands.php) should use batch processing since it runs out of memory if deleting thousands of entities about drush HOT 4 CLOSED

codebymikey avatar codebymikey commented on May 24, 2024
Drush entity:delete command (EntityCommands.php) should use batch processing since it runs out of memory if deleting thousands of entities

from drush.

Comments (4)

weitzman avatar weitzman commented on May 24, 2024

This has been possible for 3 years #4583. See --chunks option.

from drush.

codebymikey avatar codebymikey commented on May 24, 2024

Hi @weitzman,

The --chunk option doesn't actually mitigate this specific issue.

In that issue, the results of the $result = $query->execute(); call returns an array of the 1,000+ IDs, it just doesn't load or process them into full entities yet. However, if there are more IDs in the database than can be feasibly loaded in memory (e.g. millions), then the command simply doesn't work - which is why handling it within a batch context is the more robust way of handling it.

And in terms of implementation, I was thinking something along the lines of this (but we can't use n.nid > :nid type logic since the entity might not be numeric), this or this.

from drush.

weitzman avatar weitzman commented on May 24, 2024

Thanks for clarifying. Can you really run out of memory just from a few million integers? That doesnt seem like a lot of memory consumption. What is your CLI memory_limit? Can it be bumped?

from drush.

codebymikey avatar codebymikey commented on May 24, 2024

Hmm, thought about it a bit more after reviewing how many entities I had to delete (720,000), and you were right, and that seems like a feasible amount of entities IDs to be loaded in PHP. I had a memory limit of 256M on the CLI.

$ php -i | grep mem
memory_limit => 256M => 256M

And was able to resolve the issue by temporarily increasing the memory limit in my settings.php with the following:

if (PHP_SAPI === 'cli') {
  # 512M still wasn't enough.
  ini_set('memory_limit', '-1');
}

But I guess it'd just be nice to have the code optimized to not require as much memory if possible.

from drush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.