Apex heap size too large during purging after 30 days
Package Edition of Nebula Logger
Unlocked Package
Package Version of Nebula Logger
V4.12
New Bug Summary
We also use [Nebula Logger Plugin - Big Object Archiving] - Version is 0.9.
We need to retain logs for 30 days so our archiving is set to be 30 days. We get the following error when the framework tries to purge records
caused by: System.LimitException: Apex heap size too large: 13430994
External entry point Class.LogEntryArchiveBuilder.getLogEntryArchive: line 43, column 1 Class.LogEntryArchivePlugin.execute: line 62, column 1 Class.LogBatchPurger.executeApexPlugin: line 275, column 1 Class.LogBatchPurger.executePlugins: line 255, column 1 Class.LogBatchPurger.execute: line 121, column 1
@halderanindya when this error happens, does it cause all subsequent batches to fail? Or does it only cause issues with certain batches within the batch job?
@jongpie Thanks for looking into this. Yes, all subsequent batches were failing. We then manually deleted the logs.
@halderanindya thanks for the info! In that case, I don't have a quick-fix/workaround for this, but I'll look into it more when I can. Once I have a chance to look at it more, I'll let you know if I have any more questions.
My original heap size error was larger than yours @halderanindya, and to quickly fix this issue, I had to lower the default batch size in LogBatchPurger to 500.
private static final Integer DEFAULT_BATCH_SIZE = 500;
ERROR Failed to process batch for class 'LogBatchPurger' for job id '707W500001EL44v'
caused by: System.LimitException: Apex heap size too large: 28072473
External entry point Class.LogEntryArchiveBuilder.getLogEntryArchive: line 43, column 1 Class.LogEntryArchivePlugin.execute: line 62, column 1 Class.LogBatchPurger.executeApexPlugin: line 272, column 1 Class.LogBatchPurger.executePlugins: line 252, column 1 Class.LogBatchPurger.execute: line 121, column 1
I've released a fix for this in release v4.16.3 - the default batch size can now be configured with a new LoggerParameter__mdt record, and it now defaults to 500 out of the box.
If any more issues related to this come up, just let me know!
@jongpie Thanks for this fix. Awesome stuff as usual!