timgit / pg-boss

Queueing jobs in Postgres from Node.js like a boss
MIT License
2.13k stars 158 forks source link

Documentation: What exactly does `retention` mean? #206

Closed ghost closed 3 years ago

ghost commented 4 years ago

The docs for "Retention options" state that the options control

[how long] a job may be in created state before it's archived

I'm a little confused as to what that means specifically. Jobs start out as created, right? Will they expire if not picked up before the configured retention time? What about already completed jobs?

In general, a state diagram on how a job can change from state to state would be great - is there any docs about this?

timgit commented 4 years ago

Yes, the retention period is how long a job may exist in a queue if it were never picked up. They are not considered expired, which applies to active jobs that weren't completed, but rather abandoned/archived. They will stay in the archive table for another interval before being permanently deleted.

Completed jobs are moved to the same archive after 12 hours, but can be customized as well via archiveCompletedAfterSeconds.

apiel commented 4 years ago

@timgit what is the purpose to archive a job? Would it be possible to delete the job as soon as we are done with it?

ghost commented 4 years ago

Thanks for the quick response!

A few more things I'm still not clear about:

timgit commented 4 years ago

The purpose of the archive table is to manage the size of the primary job table without forcing jobs to be permanently deleted. You can control how long a job remains in the archive via configuration settings.

What about failed jobs, I'm guessing they behave like completed jobs with respect to cleanup?

Failed, cancelled and completed jobs are all considered "completed" and treated the same in regards to archival.

What about the retry status, do jobs go from active directly to retry if they fail and have a retryLimit set? Do jobs that are in retry behave like created jobs for every other purpose?

Yes, this is how it works.

ghost commented 4 years ago

I drafted a quick state diagram of all the possible states a job goes through - if you want (and it's in fact correct), I can create a PR putting it somewhere in docs?

pg-boss

timgit commented 3 years ago

Looks great! Thanks. You could add this image in a new images subfolder in /docs in the PR for relative path refs

fiznool commented 3 years ago

This diagram is super useful. However on reading #208 I thought that expired jobs can be retried if the retryLimit option is set. This isn't shown in the diagram, though?

timgit commented 3 years ago

They are retried via the retry state