Skip to content

Export to STDOUT loads entire DB into memory at once #195

@jcatello

Description

@jcatello

Since upgrading to 2.5 seeing a lot of memory issues specifically with db export when exporting to STDOUT

# wp cli version
WP-CLI 2.5.0
# wp ${WPCLIFLAGS} db export - --path="${DOCROOT}" --quiet --single-transaction --quick --lock-tables=false --max_allowed_packet=1G --default-character-set=utf8mb4 --routines --triggers --events | wp ${WPCLIFLAGS} --quiet db import - --path="${DOCROOT}" --ssh="${REMOTEHOST}":"${REMOTEPORT}" --quiet --force --max_allowed_packet=1G
PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 534773792 bytes) in phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 546

^ This failed within 10 seconds of running it, the database is very large.. 20GB but when exporting with 2.4.0 it has no issues.

# php wp-cli-2.4.0.phar ${WPCLIFLAGS} db export - --path="${DOCROOT}" --quiet --single-transaction --quick --lock-tables=false --max_allowed_packet=1G --default-character-set=utf8mb4 --routines --triggers --events | wp ${WPCLIFLAGS} --quiet db import - --path="${DOCROOT}" --ssh="${REMOTEHOST}":"${REMOTEPORT}" --quiet --force --max_allowed_packet=1G

Exporting to file is fine:

# wp db export
Success: Exported to 'wp2656528262db_28193-2021-05-20-6848253.sql'.

STDOUT:

# wp db export -
PHP Fatal error:  Allowed memory size of 1342177280 bytes exhausted (tried to allocate 1071644704 bytes) in phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 546

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions