contribsys / faktory

Language-agnostic persistent background job server
https://contribsys.com/faktory/
Other
5.71k stars 228 forks source link

Faktory unique jobs inconsistent #403

Closed ankitAtVauld closed 2 years ago

ankitAtVauld commented 2 years ago

Are you using an old version? No Have you checked the changelogs to see if your issue has been fixed in a later version?

https://github.com/contribsys/faktory/blob/master/Changes.md https://github.com/contribsys/faktory/blob/master/Pro-Changes.md https://github.com/contribsys/faktory/blob/master/Ent-Changes.md

We are running a high throughput application which is submitting Jobs to faktory in background. We used faktory unique job along with faktory schedule feature. E.g. we used at: 3 seconds and "unique_until" is set to "start"

Expected behavior: Jobs get enqueued after 3 second and no jobs with the same payload is enqueued until the first one starts. And even then, we should at max have two jobs with same params, one executing and other might be enqueued or scheduled.

Observed Behavior: Since, the amount of jobs we submit per second is higher, it results in several duplicate jobs with above config.

If we add "unique_for" with the job submission, we kind of achieve uniqueness.

It might be that our understanding is wrong, then we appreciate to be corrected. if not, please include that as a bug.

mperham commented 2 years ago

The uniqueness filter only works on jobs which have a unique_for value. I updated the first sentence here to make that more clear:

https://github.com/contribsys/faktory/wiki/Ent-Unique-Jobs#use