joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.73k stars 3.65k forks source link

[CLI] database:export "Allowed memory size bytes exhausted", php 7.4, J4 #30475

Open bato3 opened 4 years ago

bato3 commented 4 years ago

Steps to reproduce the issue

Default php 7.4 configuration from XAMMP, 389597 rows in #_finder_terms (127.9 MB on disk)

php cli\joomla.php -vvv --table=jos37_finder_terms database:export

Actual result

Exporting Database
==================

 Processing the jos37_finder_terms table
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 67108872 bytes) in C:\xampp\htdocs\libraries\vendor\joomla\database\src\DatabaseExporter.php on line 299

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 67108872 bytes) in C:\xampp\htdocs\libraries\vendor\joomla\database\src\DatabaseExporter.php on line 299
Symfony\Component\ErrorHandler\Error\OutOfMemoryError^ {#390689
  -error: array:4 [
    "type" => 1
    "message" => "Allowed memory size of 536870912 bytes exhausted (tried to allocate 67108872 bytes)"
    "file" => "C:\xampp\htdocs\libraries\vendor\joomla\database\src\DatabaseExporter.php"
    "line" => 299
  ]
  #message: "Error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 67108872 bytes)"
  #code: 0
  #file: "C:\xampp\htdocs\libraries\vendor\joomla\database\src\DatabaseExporter.php"
  #line: 299
}

System information (as much as possible)

Additional comments

I know, that I can reconfigure server, but I think we should find a solution that requires less memory.

Hackwar commented 1 year ago

I've opened an issue on the database repo: https://github.com/joomla-framework/database/issues/287

Hackwar commented 5 months ago

So the solution to this issue would be to stagger reading and writing the data from the table during export. Limit the number of rows to read, then write them to a file resource, read the next batch and write it again until done. This is a bigger refactoring and I'm unsure if our Filesystem package properly supports this.