-
Notifications
You must be signed in to change notification settings - Fork 10
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
WP-CLI Out Of Memory on search-replace actions with large serialized objects - Buffer? #64
Comments
Hello @JanThiel ! I will try to reproduce it and see if it's the buffering mechanism that produces this "effect". My preliminary analysis is that your assumption seems correct… Anyway, let's start by confirming your analysis. Can you just tell me if you can see if such a wpcli command produces many events? |
Oh, and by the way, if you really need to execute this command now, the best approach for me seems to pause the logger before the command and reactivate it after. You will be "blind" and I agree it's a dirty workaround. But it is better than other methods I can think of… |
Hey @Pierre-Lannoy, very well over here in Germany except of the common spreading stupidity. But let's not jump into politics :-) Thank you very much! Using the WP-CLI flag
In general thre aren't really any entries within Datadog about these operations as we have the log level reduced in our Prod env. That does make me wonder where Decalog enters the call stack. What did cross my mind was the question whether it might be helpful to be able to get the Decalog "outputs" printed out within a CLI session when they happen. Like the Regarding your thoughts on the Have a great night, Jan |
Hello @JanThiel !
There is already a way to do (a sort of) this (but, yes, it requires Have a nice day :) |
Hello @JanThiel 😊 I haven't been able to reproduce your issue. Even with high events-load. But I understand you experience it and so, maybe, others. So, I started from the assumption that the root cause that seemed the most likely was the right one and I implemented:
The default values are buffer size = 1000 events and no buffering for WP CLI. It is possible to change that by revealing in DecaLog options tab the "advanced settings". To do that, just add: But, as I'm not able to reproduce the issue, I have no way to verify this modification fixes it… If you want to test it, it would be marvelous 😬 |
@Pierre-Lannoy Thank you very much - as always. Highly appreciate your thoughtful and forthcoming work :-) I just needed to confirm that we have reliable test-cases to check against before getting back to you. And I am now comfortable that we have. Let me know how to give the fix a shot :-) |
Hello @JanThiel ! |
Still waiting for your reply:
|
OMG! Sorry… |
No problem and thank you very much for the clarification! 😀 I will run the test on Monday and get back to you with the result. |
Hello @JanThiel ! |
Hello @JanThiel! |
Describe the bug
Hey @Pierre-Lannoy hope you are doing well :-)
This is quite an "early" bug report while we have not yet 100% identified the root cause but having some quite reasonable ideas of it. Hoping for some highly valued input of yours.
The issue:
We face(d) massive memory spikes when using WP-CLIs
search-replace
on tables with many large (~100kb each, several 100s of them) serialized objects. These serialized objects leads WP-CLI to use PHP for the search-replace on these fields.And as such using the WP PHP API (
update_...
functions) to de-serialize, search-replace and then serialize and update the data again. Performing this on a table of ~80MB size lead to a memory consumption of >20GB ending with Out of Memory killer being triggered.Running the same
wp search-replace ...
with--skip-plugins=decalog
mitigated this issue. The search-replace went through in seconds. No memory spikes, no mentionable memory consumption.We assume - but again have not verified it yet (sorry!) - the
buffer
option of Decalog to be the root of this. If this applies to WP-CLI calls as well, it might explain the seen behaviour as the log calls with all the data in it are stored in memory and would only be logged once the CLI "request" ends?! Does that makes sense?If you agree on this as a possible source, could you suggest a "hotfix" we could try out to ignore the
buffer
option in CLI sessions? We could try this out and give you feedback on it as we have this issue reproducible ;-)Notable: We use a redis object cache (Object Cache Pro) which is inflicted as well. Yet when disabling Decalog that component does not seem to cause any issues.
And we still use Datadog as target log system.
To Reproduce
Steps to reproduce the behavior (not verified yet!):
buffer
option in Decalog is enabledwp search-replace old-value new-value wp_postmeta --dry-run
Memory should spike and the operation should take a long time.
Expected behavior
No memory spike and only some seconds execution time.
Maybe ignore the
buffer
option in CLI sessions and always flush the log calls directly? This might increase the CLI runtimes slightly but will prevent scaling effects. If these are the case here.Environment (please complete the following information):
Thank you very much as always :-)
The text was updated successfully, but these errors were encountered: