jobqueue: store an expiry date
This introduces an expiry date (default: 14 days from insert date) and adjust the service-maintenance script to delete jobs that are older than the expiration date.
This commit is contained in:
parent
37fc807bfa
commit
78ae275c61
4 changed files with 59 additions and 113 deletions
16
pkg/jobqueue/dbjobqueue/schemas/005_jobs_expiry.sql
Normal file
16
pkg/jobqueue/dbjobqueue/schemas/005_jobs_expiry.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- add the expires_at column
|
||||
ALTER TABLE jobs
|
||||
ADD COLUMN expires_at timestamp DEFAULT NOW() + interval '14 days';
|
||||
|
||||
-- We added a column, thus we have to recreate the view.
|
||||
CREATE OR REPLACE VIEW ready_jobs AS
|
||||
SELECT *
|
||||
FROM jobs
|
||||
WHERE started_at IS NULL
|
||||
AND canceled = FALSE
|
||||
AND id NOT IN (
|
||||
SELECT job_id
|
||||
FROM job_dependencies JOIN jobs ON dependency_id = id
|
||||
WHERE finished_at IS NULL
|
||||
)
|
||||
ORDER BY queued_at ASC
|
||||
Loading…
Add table
Add a link
Reference in a new issue