Merge pull request #3607 from overleaf/em-bull-completed

Keep a fixed number of completed jobs in Bull

GitOrigin-RevId: c4a1cdf9ce811be7624b46c876fca0ac1d4253c6
This commit is contained in:
Eric Mc Sween 2021-01-28 08:40:18 -05:00 committed by Copybot
parent 37d45d64b3
commit 979a2b0be5

View file

@ -3,6 +3,11 @@ const Settings = require('settings-sharelatex')
const analyticsQueues = {}
// Bull will keep a fixed number of the most recently completed jobs. This is
// useful to inspect recently completed jobs. The bull prometheus exporter also
// uses the completed job records to report on job duration.
const MAX_COMPLETED_JOBS_RETAINED = 10000
function initialize() {
if (Settings.analytics.enabled) {
analyticsQueues.events = createQueue('analytics-events')
@ -14,7 +19,7 @@ function createQueue(queueName, defaultJobOptions) {
return new Queue(queueName, {
redis: Settings.redis.queues,
defaultJobOptions: {
removeOnComplete: true,
removeOnComplete: MAX_COMPLETED_JOBS_RETAINED,
attempts: 11,
backoff: {
type: 'exponential',