-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Too much memory consumption when Klarna is doing maintenance on table klarna_logs #34515
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
Comments
Hi @TekniskSupport. Thank you for your report.
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @TekniskSupport - I believe this issue should be directed to Klarna. https://marketplace.magento.com/klarna-m2-checkout.html#product.info.details.support |
@bjornmeat Magento currently requires a pinned version of the Klarna extension, for some reason. I am assuming this is because the Magento development team actually works on the Klarna extension themselves? So even if this is reported to Klarna directly and fixed, Magento still needs to release a new version of itself in order to be able to actually fix it in Magento. |
An update in the matter! I did contact Klarna and they (somewhat) acknowledged the issue. So at least their developers are informed in the matter. |
Hi @engcom-November. Thank you for working on this issue.
|
Hi @TekniskSupport |
@engcom-November again, there is still need for action for Magento itself, see my explanation here: #34634 (comment) Reporting this with Klarna won't matter as Magento still would have to release a new versino, once Klarna released a new version. |
Hi,
When the cron job Klarna\Core\Cron\UpdateApiLog is run it creates a collection from the table klarna_logs and sets the result to class variable, this loads the entire table into memory, as it contains a lot of JSON, the result is it consumes a lot of RAM.
Klarna\Core\Cron\UpdateApiLog
From method getList in
Klarna\Core\Model\LogRepository
In our case this routine was using well over 4 GB of memory each time it ran the cron job, this caused memory related issues.
We solved it by adding a few addAttributeToSelect()'s to the collection, so that it no longer loads data it doesn't even use.
Consumtion from that job is now at less than 10% what it was (and that is including bootstrapping Magento).
For what it's worth you could optimize it further by doing a DISTINCT select for the incrementIDs.
Or even better, not even doing collections and selects just perform the task in SQL by doing an update from join.
There are similar issues in the
Klarna\Core\Cron\CleanLogs
ps.
Also note that the use of private methods made it impossible to do a simple interceptor or just overriding the problematic method.
ds.
Preconditions
1, use Magento open source edition 2.4.3
2, have klarna checkout installed and configured
Steps to reproduce
Expected result
No issues with unnecessary memory consumtion.
Actual result
Crashing cron jobs due to memory issues
The text was updated successfully, but these errors were encountered: