Skip to content

Commit

Permalink
fix(locking): ensure jobs are not locked too greedy
Browse files Browse the repository at this point in the history
  • Loading branch information
simllll committed Sep 24, 2020
1 parent 8cd1c31 commit 5bc123a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/utils/process-jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ module.exports = function(extraJob) {
// 3. Queue the job to actually be run now that it is locked
// 4. Recursively run this same method we are in to check for more available jobs of same type!
if (job) {
// Before en-queing job make sure we haven't exceed our lock limits
if (!shouldLock(name)) {
debug('lock limit reached before job was returned. Releasing lock on [%s]', name);
job.attrs.lockedAt = null;
self.saveJob(job);
return;
}

debug('[%s:%s] job locked while filling queue', name, job.attrs._id);
self._lockedJobs.push(job);
definitions[job.attrs.name].locked++;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hokify/agenda",
"version": "3.1.4",
"version": "3.1.5",
"description": "Light weight job scheduler for Node.js",
"main": "index.js",
"files": [
Expand Down

0 comments on commit 5bc123a

Please sign in to comment.