File tree Expand file tree Collapse file tree
app/api/cron/cleanup-file-versions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { type NextRequest, NextResponse } from 'next/server'
33import { verifyCronAuth } from '@/lib/auth/internal'
44import { getJobQueue } from '@/lib/core/async-jobs'
55import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
6+ import { CLEANUP_DISPATCH_MAX_ATTEMPTS } from '@/background/cleanup-dispatch'
67
78export const dynamic = 'force-dynamic'
89
@@ -21,7 +22,7 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
2122 'cleanup-dispatch' ,
2223 { jobType : 'cleanup-file-versions' } ,
2324 {
24- maxAttempts : 1 ,
25+ maxAttempts : CLEANUP_DISPATCH_MAX_ATTEMPTS ,
2526 jobId : `cleanup-dispatch:cleanup-file-versions:${ scheduleWindow } ` ,
2627 name : 'File version cleanup dispatch' ,
2728 concurrencyKey : 'cleanup-dispatch:cleanup-file-versions' ,
Original file line number Diff line number Diff line change @@ -5,12 +5,17 @@ export interface CleanupDispatchPayload {
55 jobType : CleanupJobType
66}
77
8+ /** Attempts per dispatch. A rerun only re-triggers chunks that delete already-expired data. */
9+ export const CLEANUP_DISPATCH_MAX_ATTEMPTS = 3
10+
811/**
912 * Resolves a retention job's workspace scope and fans out its per-chunk cleanup runs. The scan
10- * covers every active workspace, so it runs here rather than inside the cron request.
13+ * covers every active workspace, so it runs here rather than inside the cron request. One
14+ * dispatch at a time per job type: the route keys runs by `concurrencyKey`.
1115 */
1216export const cleanupDispatchTask = task ( {
1317 id : 'cleanup-dispatch' ,
14- retry : { maxAttempts : 1 } ,
18+ queue : { concurrencyLimit : 1 } ,
19+ retry : { maxAttempts : CLEANUP_DISPATCH_MAX_ATTEMPTS } ,
1520 run : ( { jobType } : CleanupDispatchPayload ) => dispatchCleanupJobs ( jobType ) ,
1621} )
You can’t perform that action at this time.
0 commit comments