elunez/eladmin · error · BadRequestException

定时任务暂停失败

Error message

定时任务暂停失败

What it means

QuartzManage.pauseJob simply calls scheduler.pauseJob(jobKey); a SchedulerException is logged and rethrown as BadRequestException '定时任务暂停失败'. pauseJob is also invoked from addJob/updateJobCron when a job is saved in the paused state, so this error can surface during create/update of a paused job, not only from the pause endpoint.

Source

Thrown at eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java:174

            JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getId());
            scheduler.triggerJob(jobKey,dataMap);
        } catch (Exception e){
            log.error("定时任务执行失败", e);
            throw new BadRequestException("定时任务执行失败");
        }
    }

    /**
     * 暂停一个job
     * @param quartzJob /
     */
    public void pauseJob(QuartzJob quartzJob){
        try {
            JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getId());
            scheduler.pauseJob(jobKey);
        } catch (Exception e){
            log.error("定时任务暂停失败", e);
            throw new BadRequestException("定时任务暂停失败");
        }
    }
}

View on GitHub (pinned to 55fbf70595)

Solutions

  1. Check the stack trace in the log for the exact SchedulerException.
  2. If the job key is missing, resume flows (error 33) recreate it — or simply recreate the job.
  3. Verify quartz store configuration and that the scheduler is running (scheduler.isStarted()).
Defensive patterns

Strategy: try-catch

Validate before calling

// idempotent pause: only pause keys the scheduler knows
JobKey jk = JobKey.jobKey("JOB_NAME" + job.getId());
if (scheduler.checkExists(jk)) scheduler.pauseJob(jk);
else quartzManage.addJob(job); // rebuild then pause

Try / catch

try { quartzJobService.updateIsPause(job); } catch (BadRequestException e) { if ("定时任务暂停失败".equals(e.getMessage())) { log.error("pause failed", e); return fail("暂停失败:任务调度状态异常,建议重建任务"); } throw e; }

Prevention

When it happens

Trigger: Pausing a job (updateIsPause endpoint) when the job key does not exist in the scheduler — pauseJob on a missing key throws — or when the scheduler/store is in an error state. Also triggered as part of addJob for jobs saved with isPause=true.

Common situations: Pausing a job whose scheduler entry was lost (RAM job store reset, partial deletes); clustered quartz with a failed node; scheduler in standby.

Related errors


AI-assisted analysis of elunez/eladmin@55fbf70595 (2026-08-14). Data as JSON: /api/errors/5c139c38d04bbe3b. Report an issue: GitHub.