1
0
Fork 0

Fix Foxx Queues infinite maxFailures (#7224)

This commit is contained in:
Alan Plum 2018-11-12 13:21:12 +01:00 committed by Michael Hackstein
parent 7a2314a32b
commit 1ea6374511
3 changed files with 30 additions and 7 deletions

View File

@ -26,6 +26,8 @@ v3.4.0-rc.5 (XXXX-XX-XX)
v3.4.0-rc.4 (2018-11-04)
------------------------
* fixed Foxx queues not retrying jobs with infinite `maxFailures`
* increase AQL query string parsing performance for queries with many (100K+) string
values contained in the query string

View File

@ -89,12 +89,12 @@ function getBackOffDelay(job) {
exports.work = function (job) {
var maxFailures = (
typeof job.maxFailures === 'number' || job.maxFailures === false
typeof job.maxFailures === 'number'
? job.maxFailures
: (
typeof job.type.maxFailures === 'number' || job.type.maxFailures === false
typeof job.type.maxFailures === 'number'
? job.type.maxFailures
: false
: 0
)
);
@ -150,7 +150,7 @@ exports.work = function (job) {
callback = job.success;
data.status = 'complete';
data.runs += 1;
} else if (maxFailures === false || job.runFailures > maxFailures) {
} else if (maxFailures !== -1 && job.runFailures > maxFailures) {
// mark failed
callback = job.failure;
data.status = 'failed';

View File

@ -39,20 +39,18 @@ var basePath = fs.makeAbsolute(fs.join(internal.pathForTesting('common'), 'test-
function foxxQueuesSuite () {
var cn = "UnitTestsFoxx";
var collection = null;
var qn = "FoxxCircus";
return {
setUp : function () {
db._drop(cn);
collection = db._create(cn);
db._create(cn);
queues.delete(qn);
},
tearDown : function () {
db._drop(cn);
collection = null;
queues.delete(qn);
},
@ -220,6 +218,29 @@ function foxxQueuesSuite () {
}
}
assertNotEqual(3, db.UnitTestsFoxx.count());
},
testExecuteInfinitelyFailingJob : function () {
assertEqual(0, db.UnitTestsFoxx.count());
var queue = queues.create(qn);
var id = queue.push({
name: 'peng',
mount: '/_admin/aardvark',
maxFailures: -1
}, {}, { failure: function() {
require("internal").db.UnitTestsFoxx.insert({ failed: true });
}});
for (let tries = 0; tries < 60; tries++) {
var result = db.UnitTestsFoxx.count();
if (result < 2) {
internal.wait(0.5, false);
continue;
}
queue.delete(id);
break;
}
assertNotEqual(0, db.UnitTestsFoxx.count());
}
};