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

Fixed NullReferenceException + Fixed Executing a query synchronously on an asynchronous ravenDbSession #17

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/Quartz.Impl.RavenDB/RavenJobStore.IJobStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,22 @@ public async Task StoreTrigger(IOperableTrigger newTrigger, bool replaceExisting

var scheduler = await session.LoadAsync<Scheduler>(InstanceName, cancellationToken);

var isJobGroupPaused = scheduler.PausedJobGroups.Contains(newTrigger.JobKey.Group);

// make sure trigger group is not paused and that job is not blocked
if (isTriggerGroupPaused || isJobGroupPaused)
if (scheduler != null)
{
trigger.State = InternalTriggerState.Paused;
var isJobGroupPaused = scheduler.PausedJobGroups.Contains(newTrigger.JobKey.Group);

if (scheduler.BlockedJobs.Contains(newTrigger.GetJobDatabaseId()))
trigger.State = InternalTriggerState.PausedAndBlocked;
}
else if (scheduler.BlockedJobs.Contains(newTrigger.GetJobDatabaseId()))
{
trigger.State = InternalTriggerState.Blocked;
// make sure trigger group is not paused and that job is not blocked
if (isTriggerGroupPaused || isJobGroupPaused)
{
trigger.State = InternalTriggerState.Paused;

if (scheduler.BlockedJobs.Contains(newTrigger.GetJobDatabaseId()))
trigger.State = InternalTriggerState.PausedAndBlocked;
}
else if (scheduler.BlockedJobs.Contains(newTrigger.GetJobDatabaseId()))
{
trigger.State = InternalTriggerState.Blocked;
}
}

// Overwrite if exists
Expand Down Expand Up @@ -867,12 +870,13 @@ public async Task<IReadOnlyCollection<TriggerFiredResult>> TriggersFired(

if (job.ConcurrentExecutionDisallowed)
{
var triggerCollection = session
var triggerCollection = await session
.Query<Trigger>()
.Include(t => t.Scheduler) // pre-load
.Where(t =>
Equals(t.Group, job.Key.Group) &&
Equals(t.JobName, job.Key.Name));
Equals(t.JobName, job.Key.Name))
.ToListAsync(cancellationToken);

foreach (var t in triggerCollection)
{
Expand Down Expand Up @@ -921,9 +925,9 @@ public async Task TriggeredJobComplete(IOperableTrigger trigger, IJobDetail jobD
{
scheduler.BlockedJobs.Remove(job.Key);

var triggerCollection = session.Query<Trigger>()
var triggerCollection = await session.Query<Trigger>()
.Where(t => Equals(t.Group, job.Group) && Equals(t.JobName, job.Name))
.ToList();
.ToListAsync(cancellationToken);

foreach (var t in triggerCollection)
{
Expand Down