Skip to content

Handle DELETE_OPERATION_TOO_LARGE exception #1026

Description

@manuerwin

Package Edition of Nebula Logger

Unlocked Package

Package Version of Nebula Logger

v4.19.3

New Bug Summary

Periodically receive Apex unhandled exceptions during scheduled purge batch window that delete failed due to DELETE_OPERATION_TOO_LARGE, Cascade deleting too many records for both Feed Items and Log Entries.
The log records (and child log entries) are deleted by the time I review the unhandled exceptions.

IFF the eventual deletion of the parent logs is guaranteed, would be great to handle (WARN/ERROR log?) these currently unhandled exceptions.

Failed to process batch for class 'LogBatchPurger' for job id '707RF00001g1072'

caused by: System.DmlException: Delete failed. First exception on row 0 with id a1ERF000005r1EP2AY; first error: DELETE_OPERATION_TOO_LARGE, Cascade deleting too many records: occurring when cascading to Feed Item records: []

Class.LoggerDataStore.Database.deleteRecords: line 118, column 1
Class.LoggerDataStore.Database.hardDeleteRecords: line 148, column 1
Class.LogBatchPurger.execute: line 122, column 1
Class.LogBatchPurger.execute: line 105, column 1
Failed to process batch for class 'LogBatchPurger' for job id '707RF00001g1072'

caused by: System.DmlException: Delete failed. First exception on row 0 with id a1ERF000005sgZJ2AY; first error: DELETE_OPERATION_TOO_LARGE, Cascade deleting too many records: occurring when cascading to Log Entry records: []

Class.LoggerDataStore.Database.deleteRecords: line 118, column 1
Class.LoggerDataStore.Database.hardDeleteRecords: line 148, column 1
Class.LogBatchPurger.execute: line 122, column 1
Class.LogBatchPurger.execute: line 105, column 1

Activity

  1. jongpie commented on Sep 9, 2026

    @jongpie
    Owner

    Hi @manuerwin thanks for reporting this! The purge job doesn't directly handle deleting Feed Items, so the implicit deletion of those when deleting LogEntry__c data can cause this issue. I'll look at trying to improve the code to handle this better - in the meantime, you should be able to work around it by reducing the batch size, using the included LoggerParameter__mdt record LogBatchPurgerDefaultBatchSize.

  2. added
    Layer: ConfigurationItems related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type
    Feature: Log RetentionItems related to LogBatchPurger or LogBatchPurgeScheduler
    on Sep 9, 2026
  3. manuerwin commented on Sep 10, 2026

    @manuerwin
    SponsorContributorAuthor

    Thanks @jongpie !!
    Should have said I've already tried reducing the default (500) to 100 and still getting the error, will reduce further 🤞
    IF I get some spare time 😛 will push a PR

  4. RajPabnani03 commented on Oct 1, 2026

    @RajPabnani03

    Opened a fix in #1030 (currently a draft while I sort out an API permission quirk) — LogBatchPurger now falls back to partial deletes + recycle-bin emptying when the cascade delete throws DELETE_OPERATION_TOO_LARGE, via a new virtual LoggerDataStore.Database.emptyRecycleBin for mockability, with a regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: Log RetentionItems related to LogBatchPurger or LogBatchPurgeSchedulerLayer: ConfigurationItems related to the custom hierarchy setting LoggerSettings__c or any included custom metadata typeType: BugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions