Closed stefanfisk closed 2 years ago
We are running into this too, lately. I have two servers, one is Ubuntu 20.04, the other is 21.04, and when I run a standard search-replace across the exact same database, the older server completes in one pass but the newer one takes 7 or so passes.
The older server's info is:
OS: Linux 5.4.0-89-generic #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.4
PHP version: 7.4.25
php.ini used: /etc/php/7.4/cli/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.4.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /var/www/
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.5.0-alpha-9061b3e
The newer server's info is:
OS: Linux 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.4
PHP version: 7.4.25
php.ini used: /etc/php/7.4/cli/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.6.5-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /var/www/
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.5.0
I'll try to re-run this later today or tomorrow to get exact numbers, but towards the end it finds exactly 6,000, then exactly 3,000, and then I think it is 1,000 and then 0, but I'll update when I know more.
@cjhaas Please use WP-CLI 2.5.0 stable on older server and test again.
@wojsmol , unfortunately do to time constraints I was only able to do the opposite, which is run alpha on the new server, and that worked as expected, all replacements ran in the first pass.
If I get a chance this weekend, I'll see if I can debug this further
@cjhaas Did you run the same phar file or fresh nightly? Additio9nally please check innodb_default_row_format
on new server.
@wojsmol , I copied the alpha phar from my older server, so it is identical. Both servers have a value of dynamic
for that variable.
For MySQL, they are both stock unmodified installs using:
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
apt install mariadb-server-10.6
(replacing the version appropriately)
You might be able to potentially rule out the InnoDB settings — I just hit this issue earlier today when trying to update a database, so I figured I'd try using the --precise
option (which I believe is supposed to do everything with PHP instead of sometimes with SQL queries, right?), but it still took multiple attempts. Same thing too, some tables were stopping at multiples of 1000, but not in an order that makes sense. Had a postmeta table do 3000, then 1814, then 1000.
I was running it locally — WP-CLI 2.5.0, MariaDB 10.6.4, and PHP 8.0.12 installed with Homebrew on latest macOS.
Okay, this appears to be fixed in #162 actually
However, the replacement is happening within each chunk, which breaks the $offset handling, causing every second chunk to be missed. This makes it necessary to run a query multiple times to ensure all occurrences are replaced.
This PR defers the actual updates until after the full search. This is still worse in terms of memory management that completely isolated chunking, but it should still be an overall improvement while making the replacements in a reliable way.
@cjhaas You can test if #162 fixes the issue by running your test with latest nightly available here or by running wp cli update --nightly
Just thought I would reply since I have a site with the same issue. I just tested nightly (2.5.1-alpha-76fabae) and it fixed the problem for me. :)
Fixed with v2.6.0 release.
Bug Report
Describe the current, buggy behavior
When running
search-replace
commands on a quite large DB, not all replacements are made. Running the command in a loop until it outputs `Success: Made 0 replacements." does eventually replace all occurrences.The string I'm replacing is the site hostname, so a large part of the rows are affected.
The command I'm running is essentially
wp db search-replace --all-tables --report-changed-only www.customer.com customer.test
. I've tried all variations of the command that I could come up with (including with and without--precise
), but it makes no difference.Here's the size of the DB:
On the 1st run I get:
2nd:
3rd:
4th:
5th, 6th:
And the 7th just
Success: Made 0 replacements.
.Describe how other contributors can replicate this bug
Right now I don't have any other way of reproducing the issue except using my customer's DB dump. If needed, I'll get a repo together where it can be reproduced. Is it possible to create large DBs inside a test feature in the repo?
Describe what you would expect as the correct outcome
All replacements should be done in a single run.
Let us know what environment you are running this on