diff --git a/NEWS.md b/NEWS.md index 6178bf32..7c2ba05a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,8 @@ Enhancements: New features: * Batch queries use per user-queues. * Batch queries queues can limit the number of queued jobs per user. + - Default is 64 jobs. + - Configuration key `batch_max_queued_jobs` allows to modify the limit. 1.38.2 - 2016-10-13 diff --git a/batch/job_backend.js b/batch/job_backend.js index 39823d17..ae522f20 100644 --- a/batch/job_backend.js +++ b/batch/job_backend.js @@ -7,7 +7,7 @@ var JobStatus = require('./job_status'); function JobBackend(metadataBackend, jobQueue) { this.metadataBackend = metadataBackend; this.jobQueue = jobQueue; - this.maxNumberOfQueuedJobs = global.settings.batch_max_queued_jobs || 250; + this.maxNumberOfQueuedJobs = global.settings.batch_max_queued_jobs || 64; this.inSecondsJobTTLAfterFinished = global.settings.finished_jobs_ttl_in_seconds || 2 * 3600; // 2 hours } @@ -98,7 +98,10 @@ JobBackend.prototype.create = function (job, callback) { } if (size >= self.maxNumberOfQueuedJobs) { - return callback(new Error('Failed to create job, max number of jobs queued reached')); + return callback(new Error( + 'Failed to create job. ' + + 'Max number of jobs (' + self.maxNumberOfQueuedJobs + ') queued reached' + )); } self.get(job.job_id, function (err) { diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 44ab7ed3..8bbe5fd4 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -33,7 +33,7 @@ module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 12 * 3600 * 1000; // 12 hours in milliseconds module.exports.batch_log_filename = 'logs/batch-queries.log'; // Max number of queued jobs a user can have at a given time -module.exports.batch_max_queued_jobs = 100; +module.exports.batch_max_queued_jobs = 64; // Max database connections in the pool // Subsequent connections will wait for a free slot. // NOTE: not used by OGR-mediated accesses diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 12f69fe1..b69c3b07 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -34,7 +34,7 @@ module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 12 * 3600 * 1000; // 12 hours in milliseconds module.exports.batch_log_filename = 'logs/batch-queries.log'; // Max number of queued jobs a user can have at a given time -module.exports.batch_max_queued_jobs = 100; +module.exports.batch_max_queued_jobs = 64; // Max database connections in the pool // Subsequent connections will wait for a free slot.i // NOTE: not used by OGR-mediated accesses diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index ec0e7925..af890e96 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -34,7 +34,7 @@ module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 12 * 3600 * 1000; // 12 hours in milliseconds module.exports.batch_log_filename = 'logs/batch-queries.log'; // Max number of queued jobs a user can have at a given time -module.exports.batch_max_queued_jobs = 100; +module.exports.batch_max_queued_jobs = 64; // Max database connections in the pool // Subsequent connections will wait for a free slot. // NOTE: not used by OGR-mediated accesses diff --git a/config/environments/test.js.example b/config/environments/test.js.example index c3cdda1f..b5782c20 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -31,7 +31,7 @@ module.exports.finished_jobs_ttl_in_seconds = 2 * 3600; // 2 hours module.exports.batch_query_timeout = 5 * 1000; // 5 seconds in milliseconds module.exports.batch_log_filename = 'logs/batch-queries.log'; // Max number of queued jobs a user can have at a given time -module.exports.batch_max_queued_jobs = 100; +module.exports.batch_max_queued_jobs = 64; // Max database connections in the pool // Subsequent connections will wait for a free slot. // NOTE: not used by OGR-mediated accesses diff --git a/test/acceptance/batch/queued-jobs-limit.test.js b/test/acceptance/batch/queued-jobs-limit.test.js index 6f110d95..d94577f5 100644 --- a/test/acceptance/batch/queued-jobs-limit.test.js +++ b/test/acceptance/batch/queued-jobs-limit.test.js @@ -71,7 +71,8 @@ describe('max queued jobs', function() { createJob(self.server, 400, function(err, res) { assert.ok(!err); - assert.equal(res.error[0], "Failed to create job, max number of jobs queued reached"); + assert.equal(res.error[0], "Failed to create job. Max number of jobs (" + + global.settings.batch_max_queued_jobs + ") queued reached"); done(); }); });