-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
LogBatchPurger Too many DML rows: 10001 #166
Comments
Hey @starkguerraj - I'll have to work on optimizing that batch job, but as a quick workaround, you can try re-running the batch job with a smaller batch size (the default is 200). Try running this Apex script to see if it'll successfully delete your records: Integer batchSize = 100;
Database.executeBatch(new LogBatchPurger(), batchSize); |
Definitely will do that for now, I tried 10 then moved down to 1 to finish off a few that were failing. Thanks |
* potential fix for #166 by introducing limits-minded deletion mechanism in LogBatchPurger * Re-added code coverage for while loop * Prettier formatting, extra safety
@starkguerraj I went ahead and took care of this one for you - @jongpie will be releasing Version |
You guys are great, I really appreciate it. |
@starkguerraj I was a little slow in release version Let us know if you run into any other issues! |
Thanks for the update, I was able to get the package installed, bad news unfortunately, received an exception this morning, here is the stack trace from the email, let me know if there's anything else I can provide. Failed to process batch for class 'LogBatchPurger' for job id '7073Z0000DQd275' caused by: System.LimitException: Too many DML rows: 10001 Class.LogBatchPurger.LogDeleter.hardDelete: line 65, column 1 |
@starkguerraj, darn, I thought we had this resolved! Sorry for the ongoing issues! I think there are a couple of next steps:
|
No big deal, just wanted to keep it on the radar. The last option seems like a great interim solution with a low amount of development effort for something that may be an edge case issue (me). |
Sounds good, I'll plan to add the extra constructor in the next release (as well as some other optimizations for the actual deletion process) - I've reopened this issue too. |
@starkguerraj the newest release, v4.6.0, has 2 related changes:
|
I was finally able to update my sandbox org from 4.5 to the latest unlocked 4.6.9. Unfortunately there is a new error now, I attempted to execute the purger to test as follows, Database.executebatch(new LogBatchPurger(), 1). It doesn't appear I'm over the limits as the error may suggest so perhaps its an internal issue, please let me know if there's something else I can provide to help you track this down. |
Hi @starkguerraj - glad you were able to upgrade to v4.6.9! You're right, I don't think a batch size of 1 is ideal for your org any more. I think a batch size of 200 (Salesforce's default batch size when calling And to give some more context on the batch job's design, as you noted,
Let me know what batch size you end up using and/or if you run into any more issues! |
Thanks for the update and explanation. Prior to your response I arbitrarily picked 10000 to see what would happen and it appeared to execute without issue. On a side note, it looks like there may be a separate issue now, there looks to be a bunch of Log records with no Entries and no start times that are well beyond my retention date that were not deleted. This may or may not have been an issue previously. |
@starkguerraj that's awesome that it worked for such a large batch size (I think that it probably used a batch size of 2,000, even though you specified 10,000, since 2,000 is the max). This really helps confirm that the optimizations/new approach have helped - thanks for confirming that! As far as those strange log records, it could be 1 of 2 scenarios:
In both of these 2 scenarios, the end result would look exactly like your screenshot - Either way, I think I can solve these scenarios by updating |
They definitely have helped, thanks for that. There is a retention date, some a few months old and some as recent as today (post logger upgrade), so I'm not sure which situation would have applied. It does sound like deleting logs with no entry records would resolve the issue, and I cant really see a good reason to keep Logs without any entries. |
@starkguerraj sounds good, thanks for confirming those details. I've created issue #223 to update the batch job to delete any logs with 0 log entries. In the meantime, if you run into any other issues (or find out any more interesting details on those strange log records), let me know! |
Getting this error for a batch whenever LogBatchPurger runs.
Almost latest version 4.4.5 of the Unlocked Package.
Will try to get some more details.
The text was updated successfully, but these errors were encountered: