Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger state stays on ERROR state even using the statrategy of ResetTriggerFromErrorState or RescheduleJob #2204

Open
eddycn3 opened this issue Nov 23, 2023 · 1 comment

Comments

@eddycn3
Copy link

eddycn3 commented Nov 23, 2023

Describe the bug

Im facing a issue that when the trigger becomes on error state this never come back to normal(waiting) state. Im using this code on the JobListener in the JobWasExecuted method:

     public async Task JobWasExecuted(IJobExecutionContext context, JobExecutionException jobException, CancellationToken cancellationToken)
     {
         if (jobException != null)
         {
             ITrigger acctualTrigger = context.Trigger;
   
             var statusTrigger = await context.Scheduler.GetTriggerState(acctualTrigger.Key, cancellationToken);

             if (statusTrigger == TriggerState.Error || statusTrigger == TriggerState.Blocked || statusTrigger == TriggerState.Paused)
             {
                 await context.Scheduler.ResetTriggerFromErrorState(acctualTrigger.Key, cancellationToken);
             }
             else
             { 

                 TriggerBuilder newTriggerBuilder = acctualTrigger.GetTriggerBuilder();
    
                
                 int retryDelay = 120000;
                 DateTimeOffset newTriggerTime = DateTimeOffset.UtcNow.AddMilliseconds(retryDelay);
    
                
                 ITrigger newTrigger = newTriggerBuilder.StartAt(newTriggerTime).Build();
    
               
                 await context.Scheduler.RescheduleJob(acctualTrigger.Key, newTrigger, cancellationToken);
             }
         }
    
         return;
     }

I don't have the idea how to solve this problem... I implemented this code using the IJobListener interface from the documentation, but seems that is not working as expected. Any help i would be thankful!

Version used
3.6.2

To Reproduce

Expected behavior

The trigger associated with the job recovers from the error state.

Additional context

@eddycn3 eddycn3 changed the title Trigger state stays on ERROR state even using the statetgy of ResetTriggerFromErrorState or RescheduleJob Trigger state stays on ERROR state even using the statrategy of ResetTriggerFromErrorState or RescheduleJob Nov 23, 2023
@lahma
Copy link
Member

lahma commented Dec 6, 2023

Does your job have some sort of logic in constructor that can break. I've seen cases where people do silly thing in job constructor like calling I/O or database which can fail and then Quartz considers the whole constructor being problematic and marking it to be unusable (error state).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants