Skip to content

Commit

Permalink
fix: only unlock jobs with a next run at date on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
simllll committed Nov 19, 2020
1 parent 12ff7e7 commit a458aea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/JobDbRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export class JobDbRepository {
* Internal method to unlock jobs so that they can be re-run
*/
async unlockJobs(jobIds: ObjectId[]): Promise<void> {
await this.collection.updateMany({ _id: { $in: jobIds } }, { $unset: { lockedAt: true } });
await this.collection.updateMany(
{ _id: { $in: jobIds }, nextRunAt: { $ne: null } },
{ $unset: { lockedAt: true } }
);
}

async lockJob(job: JobWithId): Promise<IJobParameters | undefined> {
Expand Down

0 comments on commit a458aea

Please sign in to comment.