Skip to content

Commit 89952c1

Browse files
committed
Tweak runs cleanup
For each repository, keep last run of each type+status instead of just status. Otherwise, in the case infrequent fetches (for pessimized repositories), but frequent successful parses, latest successful fetch run may be removed, leaving either no fetch runs, or a (much older) failed fetch run.
1 parent ee6c18a commit 89952c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql.d/update/update_post.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ WITH preserved_runs AS (
2929
ORDER BY start_ts DESC
3030
) AS depth,
3131
row_number() OVER (
32-
PARTITION BY repository_id, status
32+
PARTITION BY repository_id, type, status
3333
ORDER BY start_ts DESC
3434
) AS status_depth
3535
FROM runs
3636
) AS tmp
3737
WHERE
3838
-- keep failed runs for some time (assuming someone may keep a link to them)
3939
(status = 'failed'::run_status AND start_ts > now() - INTERVAL '31' DAY) OR
40-
-- keep last run of any kind (limiting age here allows last failed runs to expire)
40+
-- keep last run of each kind (limiting age here allows last failed runs to expire)
4141
(start_ts > now() - INTERVAL '31' DAY AND status_depth = 1) OR
4242
-- keep normal runs for some time
4343
(start_ts > now() - INTERVAL '3' DAY) OR

0 commit comments

Comments
 (0)