When a Salesforce transaction reaches a governor limit, retrying the same work inline usually hits the same ceiling. The reliable pattern is to re-queue the unfinished work as asynchronous jobs, such as Queueable Apex, batch chunks or Platform Event subscribers. Each unit gets its own allowance, and a failed unit can retry without the whole process starting over.
Why an inline retry hits the same ceiling
A governor limit caps how much work one transaction can consume. The caps cover SOQL queries, DML statements, heap, CPU time and callout time. When code reaches one of them, a retry loop in the same transaction draws from the same spent budget. The loop burns more time, the user waits longer, and the record still fails. Re-queueing changes where the remaining work runs, and the new job starts with its own allowance.
This changes the design review. If a process needs more queries than one synchronous transaction allows, adding another attempt does nothing. Splitting the work so each unit fits inside its own transaction does. Treat a limit failure as a sign that the unit of work is too large, and read the error text before deciding it is a transient glitch.
Compare the synchronous and asynchronous ceilings
The synchronous and asynchronous contexts do not give a unit of work the same budget, so a process sized for one can fail in the other. Confirm the figures that apply to your own org and edition before you commit to a design, since they can vary by edition and change over time. The five categories below are the first place to look when a process fails on a limit.
- SOQL queries: count the queries each unit runs, and check whether that count grows with the number of child records under each parent.
- DML statements: count statements, not records. Collect records into lists and write each list in one statement.
- Heap size: watch large collections held in memory at the same time, not just the total volume the job touches.
- CPU time: look for nested loops over large collections, since their cost grows with volume.
- Callout time: add up the time spent waiting on every external call in one transaction, because the waits accumulate.
Moving the work to async changes the context, not the logic. A loop that writes one record per statement issues the same number of statements in a queued job, so fix the loop before you move it. If the terms are new to your team, the governor limits guide for admins defines them before you design anything.
Set a working ceiling below the hard limits
Design so that normal runs stay well below the limits. A workable rule is to treat about 70 percent of each limit as the working ceiling and keep 30 percent in reserve for spikes. A process that uses 95 percent of the SOQL budget on an ordinary day has no room when volume grows, and moving it to async postpones the failure.
Measure in a sandbox with production-like volume, and record how close each unit gets to each limit. Test the largest parent records you have rather than the average, because limit use often grows with the number of child records under each parent.
Pick the async pattern that fits the failure
The right pattern depends on the shape of the work, not on which pattern the team already knows.
- Queueable Apex fits one operation with a few sequential steps. It supports chaining, so each step can enqueue the next and pass complex object parameters.
- Batch Apex fits large record sets. Each chunk runs as its own unit, and a failed chunk does not stop the others, so the job can complete the bulk of its work while a targeted retry handles the rest.
- Platform Events fit work that another system or subscriber should pick up. Subscribers can ask for a failed event to be retried, but replaying the original transaction needs custom design.
- Flow error handling fits declarative processes where an exception should route to a recovery flow.
Mixing patterns is normal. A common shape is a batch that processes records in chunks, where each failed chunk writes its failed record IDs to a custom object so a later run can pick them up. Large migration loads need the same unit splitting, so compare the options in choosing Salesforce Data Loader options for migration before you pick one.
Plan the async queue before retries start
Async work shares capacity. Asynchronous jobs draw on a daily allowance that the whole org shares, so a retry design that enqueues one job per failed record can spend that allowance quickly. The spillover then reaches other processes, including the nightly work you did not change.
Batch jobs also compete for a limited number of concurrent slots. Jobs beyond that wait in the Apex Flex Queue and start as slots open. When you plan a nightly load alongside retries, count the queued batches as well as the running ones, because a waiting batch can look like a stalled one.
Build retry logic around transient failures
Retry failures that can change on their own, such as a temporary lock or an external endpoint that is briefly unavailable. Errors from bad data, missing required values or a rule that rejects the record fail the same way on each attempt. Send those to an error record for a person to review. When the rejection comes from a validation rule, read how to write validation rules without breaking integrations before you change the rule.
For transient failures, use exponential backoff so each attempt waits longer than the one before. Cap the number of attempts, and record the outcome of each attempt. Use error tracking on the AsyncApexJob record to see which job failed and how often, so a fixed retry count keeps one bad unit from holding the queue indefinitely.
Make each unit idempotent. If a chunk runs twice, it should not create duplicate records or send a duplicate callout. Check for an existing record by an external ID or a stored key before writing. Teams often skip this step, and skipping it tends to create the cleanup work that follows a bad retry.
Handle external systems that are down
When an outside system is unavailable, a user-facing transaction should not wait for it. Queue the request through Platform Events and let it process when the system returns. The save completes without waiting on the external system, and the outage stays off the user’s screen.
Add a circuit breaker so the integration stops calling an endpoint that is already failing, then retries after a set interval. Store the breaker state where all processes can read it, so a second process does not keep calling an endpoint the first one has already stopped.
Monitor both sides. Establish whether the platform itself is healthy before you blame the integration, because that answer decides where to look first. When the platform is healthy, the cause usually sits in the integration path or the external system.
A sequence for moving a failing process to async
- Reproduce the failure in a sandbox with production-like volume and note which limit is reached. Build the sandbox copy from your sandbox refresh planning steps.
- Record whether the failure happens in a synchronous or asynchronous context, along with the record counts at the point of failure.
- Split the work into units that succeed or fail on their own, such as a batch chunk, a queue step or an event.
- Make each unit idempotent so a rerun does not duplicate writes or callouts.
- Set a maximum retry count for transient failures, and route anything over the limit to an error record.
- Force one failure on purpose and confirm that the remaining units still finish.
- After go-live, watch the queue depth and the daily async execution count across the first few cycles.
For help planning this work, see Salesforce implementation.
Questions about re-queueing governor limit failures
Does moving work to an async job remove the governor limits?
No. Asynchronous jobs get their own budgets, and some of those budgets are set differently from the synchronous ones. Each job still has limits, so the change does not remove the need to split large units. Async helps a sizing problem only when the work also fits inside the new budget.
How many retries should a failed unit get before someone reviews it?
There is no fixed number for each process. A short cap, such as three attempts with backoff, is a reasonable starting point for a transient failure. Stop earlier when the same error message repeats, because that usually points to the data or the code rather than timing.
How do I size the async queue for a nightly data load?
Start by counting the planned units: batch chunks, queued jobs and published events. Add the retry allowance you expect on a normal night, then compare the total with the daily async allowance for your org. Check how many batches can run at once as well, because a load can fit the daily allowance and still back up behind other batch jobs.
What should I check first when a batch job stops after a few chunks?
Open the AsyncApexJob record for the job to see its status and error details. A job that ran and then failed usually points to the chunk that threw the error. A job that is still waiting may be sitting behind other batches in the Apex Flex Queue, which is a capacity question rather than a code problem.
Does a sandbox test prove a re-queued process will hold in production?
It proves the code path and the limit behavior at the volume you load. It does not reproduce production timing or concurrency. Repeat the test with production-like record counts, and run it while other jobs are active so the queue behaves as it would on a busy day.