[backend/queue] Clear change tracker before saving the job state
This prevents a queue worker stall when a job fails to execute due to a database exception (leaving unsaved changes in the DbContext change tracker, preventing the job status from being set as failed)
This commit is contained in:
parent
aec5fa2698
commit
8fb7c8a93e
1 changed files with 2 additions and 0 deletions
|
@ -460,6 +460,7 @@ public class PostgresJobQueue<T>(
|
|||
logger.LogTrace("Job in queue {queue} was delayed to {time} after {duration} ms, has been queued since {time}",
|
||||
name, job.DelayedUntil.Value.ToLocalTime().ToStringIso8601Like(), job.Duration,
|
||||
job.QueuedAt.ToLocalTime().ToStringIso8601Like());
|
||||
db.ChangeTracker.Clear();
|
||||
db.Update(job);
|
||||
await db.SaveChangesAsync(token);
|
||||
await RaiseJobDelayedEvent(db);
|
||||
|
@ -484,6 +485,7 @@ public class PostgresJobQueue<T>(
|
|||
}
|
||||
}
|
||||
|
||||
db.ChangeTracker.Clear();
|
||||
db.Update(job);
|
||||
await db.SaveChangesAsync(token);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue