Add AsyncResultCleanupBatch with per-track retention#43
Merged
Conversation
Dual retention for AsyncResult__c cleanup: failedOlderThanDays(...) for FAILED results, othersOlderThanDays(...) for the rest. Explicit config required, dormant until scheduled. Also cache QueueableJob.className (transient) so the intentional TypeException logs once per job, document that expected exception (issue #42), and fix the broken vitepress containers in the queueable docs. Closes #2
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🧪 Apex Test Results✅ All Tests Passed📦 Download Full Test Results & Logs 📊 Stats: 159 total | ✅ 159 passed | ❌ 0 failed |
Use 'delete as system scope' so the cleanup batch works regardless of the running user's delete permission on AsyncResult__c. Drop the redundant className cache comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AsyncResultCleanupBatch(global, packaged): deletes oldAsyncResult__crecords with separate retention per track.failedOlderThanDays(n)coversFAILED,othersOlderThanDays(n)covers the rest (COMPLETED + SKIPPED_*). Explicit config required, at least one track, days > 0. Dormant until scheduled via the lib itself:Async.batchable(new AsyncResultCleanupBatch().failedOlderThanDays(90).othersOlderThanDays(30)).asSchedulable()...QueueableJob.classNamein a transient property so the intentional DateTime-castTypeExceptionlands in debug logs once per job instead of on every access. Transient means the cached value never survives serialization, so a deserialized job always recomputes from its own runtime type (no cross-class contamination). Context: Receiving error "System.TypeException: Invalid conversion from runtime type CleanupFinalizer to Datetime" in logs #42.:::containers that prettier's proseWrap had mangled (title swallowed the body text, literal:::rendered on the page).create-unlocked-package-version.sh.Why
AsyncResult__cgrows unbounded (#2). Failed results usually need longer retention for debugging than the rest, so two independent tracks. The #42 reporter was alarmed by the expected TypeException in logs, so it is now documented and logged far less often.Closes #2
Test plan
bash scripts/agent/verify.sh fullpassed: 159/159, org coverage 99%, new class 100%bash scripts/agent/verify.sh nspassed: 18/18 consumer scripts on the btcdev scratchbtcdev.AsyncResultCleanupBatch. Beta and scratch deleted after.Files