Closed leventov closed 4 years ago
I haven't noticed this happening in my usage. Please include the relevant constructor options you're using.
Can you run the following query?
select count(*) from pgboss.job where name = '__pgboss__maintenance'
Based on your config, you should have approx 60 jobs at any given point in time, based on your maintenance interval of 1 per minute and the default archive interval of 1 hour.
I'll push a patch soon to set the retention period for maintenance jobs to something more appropriate, but the focus will be the queue's completion jobs, which far outnumber the primary queue because of a lack of an completion subscription for them.
For example, you should see a much higher number from the following query.
select count(*) from pgboss.job where name = '__state__completed____pgboss__maintenance'
select count(*) from pgboss.job where name = 'pgbossmaintenance'
183
Can you add an event listener to the maintenance
event with console logging? I see you have multiple docker containers + p-memoize, so I'm curious which instances are picking up the jobs and the frequency of the creation and how it's working with that library. I typically only run pgboss.start() once in my apps, and it seems like p-memoize was designed to handle this use case.
Also, I just published a beta release of the patch if you want to install it as a preview. This should remove the need of the manual cleanup script you're running.
npm i pg-boss@4.0.2-beta
Nevermind, I think I have a good idea of what's happening here. It's a multi-master issue that I'll fix.
Ok, I'm pretty sure I have a fix published now in beta. I'm going to be pushing this in apps here this week to monitor it for a bit before I drop the beta tag.
npm i pg-boss@4.1.0-beta1
With 60 seconds as the maintenance interval, I see 4 times more maintenance jobs are published, with 50-2-2-6 cadence:
2020-03-22T07:58:47.011Z ... at Boss.maintenanceAsync (boss.js:56:31) at Boss.supervise (boss.js:46:16) PgBoss.start (index.js:87:23)
2020-03-22T07:59:37.170Z - 50 seconds later ... at Boss.onMaintenance (boss.js:79:18) - the same location for the rest of the ocurrences
2020-03-22T07:59:39.193Z - 2 seconds later 2020-03-22T07:59:41.214Z - 2 seconds later 2020-03-22T07:59:47.242Z - 6 seconds later 2020-03-22T08:00:37.353Z - 50 seconds later ...