Job Queue Errors That Repeat Every Night: Breaking the Loop
Restarting a failed job queue entry feels like fixing it. The entry goes back to work, the error disappears from view, and everyone moves on, until the same error returns the next night, at roughly the same time, for roughly the same reason. That pattern is the clue. A job that errors every night is not unlucky. It is faithfully re-running the same failing condition, and the restart changed nothing about that condition.
The myth: 'just restart it', and why the loop disagrees
Start with what a restart actually does. Job queue entries stop running when there is an error (s1). Restarting the entry runs the same job, with the same data and the same code, against the same condition that stopped it. Sometimes that is enough: a temporary failure, such as an external service being briefly unavailable, may have cleared by the next attempt.
But Microsoft's own guidance draws the line clearly: if a restart does not help, the issue might be in the code (s1). In other words, a restart is a test, not a treatment. One restart that succeeds tells you the failure may have been transient. A restart that fails the same way, night after night, tells you the condition is still there, and the job is doing exactly what it was asked to do, against data or code that cannot succeed.
For retail, the cost of the loop is easy to miss. The failing job is often a night-time process, the kind of run nobody watches live. Each morning starts with the same workaround instead of a finished job, and the workaround quietly becomes the process.
Read the loop: log entries, stack trace, and the first night it failed
Before changing any setting, read the failure properly. Use this procedure:
- Open the Job Queue Log for the entry. Find the repeated error, not just the most recent one. Note whether the error text is identical each night or changes.
- Read the AL stack trace. Microsoft points to the stack trace in the Job Queue Log as the way to identify the owner or publisher of the code involved (s1). That tells you whether the failing code is standard, an extension, or something custom, and therefore who can fix it.
- Find the first night it failed. A job that ran for months and then started failing points to something that changed around that first failure: data, setup, or code. A job that has never run clean is a different problem.
- Record the support details. If the issue goes to support, Microsoft asks for the job queue entry run ID, the error timestamp, and your timezone; newer versions offer a Copy details action for this (s1).
What success looks like: you can state, in one sentence, what condition the job hits when it fails, not just that it fails. Without that sentence, every later step is guessing.
Separate the classes: transient, data, code, and not-running-at-all
Recurring errors fall into distinct classes, and each class has a different fix:
- Transient. An external service or resource was unavailable at run time. This is the class the built-in retry settings were designed for (s1).
- Data or setup. The job runs, reaches the same record or condition, and stops. The stack trace points at where; the underlying record or setup is usually what needs correcting.
- Code. A restart that does not help is Microsoft's signal that the issue might be in the code (s1). No schedule or retry setting fixes code, the owner or publisher identified from the stack trace has to.
- Not running at all. An entry stuck at Ready is a different symptom from an entry in Error. Community troubleshooting notes that this can mean the Job Queue Dispatcher background session is not running, while foreground runs still work because they use your own session (s3). Checks offered for that case include the job queue category assignment, Start Job Queue in SaaS, background sessions being enabled in the Admin Center, and on-premises service configuration (s3).
The decision framework is simple: match the fix to the class. Retries for transient failures. Correction for data and setup. The code owner for code. Dispatcher and session checks for an entry that never starts. Applying the transient fix to the other three classes is what creates the nightly loop.
Tune the safety net: attempts, rerun delay, and category separation
Once the condition is understood, the built-in safety net has two settings. Maximum No. of Attempts and Rerun Delay (sec.) can keep an entry running until an external service becomes available again (s1). Used deliberately, they ride out a brief outage without a human restarting anything at midnight.
Used blindly, they do something else: they repeat the same deterministic failure several times a night instead of once. Attempts and delay do not change the outcome for a data, setup, or code error, they only change how often it fails before stopping. Tune them after the class is known, not before.
Category separation matters in the not-running case: the checks for a stuck entry include its job queue category assignment (s3). Keeping unrelated jobs from sharing one entry's fate makes the next failure easier to read, one entry, one job, one error to explain.
Fix the drift: starting times that stay put night after night
Some 'wrong time every night' complaints are not errors at all. They are schedule drift. A Dynamics Community answer documents a job set to run every 720 minutes drifting because the recurrence is calculated from the end time of the previous run, not from a fixed time of day (s4). If a run finishes later than usual, the next run starts later too, and the drift compounds.
The workaround given in that answer is to create two job queues. AM and PM, with fixed Starting Times, instead of relying on one 12-hour recurrence (s4). The principle transfers to nightly retail jobs: if a job must start at a set time, anchor it to a fixed starting time rather than to an interval counted from whenever the previous run happened to end. A job that starts late can also collide with the next process in the night sequence, which then looks like a second, unrelated failure.
Decide on auto-restart: when a restarter helps and when it hides a fire
The tempting shortcut is a restarter: a small codeunit that watches for failed entries and restarts them automatically. A published example filters Job Queue Entry records on Status = Error, with a Parameter String object filter, and calls the built-in Restart() method on each match (s2). The same post notes a useful design point: keeping the restarter isolated in its own app avoids the monitoring job itself becoming a failure point (s2).
Decide with this test:
- A restarter can help when the failure class is known to be transient, the job is safe to re-run, and someone still reviews the log, the restarter buys time, it does not close the issue.
- A restarter hides a fire when the error is deterministic. Restarting a data, setup, or code failure automatically just moves the failure out of sight. The nightly error becomes a nightly silent failure, discovered later and with less evidence.
- Never let the restarter be the diagnosis. If entries are being restarted every night, the log is still telling the same story, read it, classify it, and fix the condition.
Breaking the loop, in order: read the log and the stack trace, name the failing condition, fix that condition, then, and only then, tune attempts, rerun delay, and starting times so a genuinely temporary failure no longer needs a human at midnight.
, Dex Carter, Tech Writer
IndexBack to all guides →