File tree Expand file tree Collapse file tree
ee/workspace-forking/lib/background-work Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,9 +189,8 @@ export async function runCleanupFileVersions(payload: CleanupJobPayload): Promis
189189export const cleanupFileVersionsTask = task ( {
190190 id : 'cleanup-file-versions' ,
191191 /**
192- * Sized from production telemetry: peak RSS 219 MB across ~15,600 runs, so
193- * `small-2x` (1 GB) holds over four times the worst case. Each pass works in
194- * bounded batches of version rows, so the peak does not grow with backlog.
192+ * Each pass works in bounded batches of version rows, so peak memory stays well under
193+ * `small-2x` (1 GB) and does not grow with backlog.
195194 */
196195 machine : 'small-2x' ,
197196 maxDuration : 600 ,
Original file line number Diff line number Diff line change @@ -50,18 +50,15 @@ const EXECUTION_DEADLINE_ERROR = getTimeoutErrorMessage()
5050/**
5151 * Table jobs run as detached workers with progress heartbeats, independently of workflow timeout
5252 * policy. A running job is treated as dead once its last progress write (`updatedAt`) is older
53- * than this. It measures the gap since the last heartbeat, not run length, so it does not track
54- * any task's `maxDuration`; it only has to exceed the longest stretch a live worker goes without
55- * writing progress.
53+ * than this, so it must exceed the longest gap between a live worker's heartbeats.
5654 */
5755const TABLE_JOB_STALE_THRESHOLD_MINUTES = 95
5856/** Terminal table-jobs older than this are pruned; only the latest job per table is ever read. */
5957const TABLE_JOB_RETENTION_HOURS = 24
6058/**
6159 * A table run dispatch whose holder has not made progress for this long is
62- * treated as dead. Same shape and window as the table-job threshold above,
63- * measured from the dispatcher's own per-window heartbeat rather than from when
64- * the run was requested, so it is independent of the task's `maxDuration`.
60+ * treated as dead. Same rule as the table-job threshold above, measured from the
61+ * dispatcher's own per-window heartbeat rather than from when the run was requested.
6562 */
6663const TABLE_DISPATCH_STALE_THRESHOLD_MINUTES = 95
6764/** Per-run ceiling on reaped dispatches, so one tick cannot fan out unbounded SSE. */
Original file line number Diff line number Diff line change 11import { task } from '@trigger.dev/sdk'
2+ import { STALE_ACTIVE_MS } from '@/ee/workspace-forking/lib/background-work/store'
23import {
34 type ForkContentCopyPayload ,
45 runForkContentCopy ,
@@ -21,13 +22,11 @@ export const forkContentCopyTask = task({
2122 id : 'fork-content-copy' ,
2223 machine : 'large-2x' ,
2324 /**
24- * Inside `STALE_ACTIVE_MS` (30 minutes, in the background-work store), after
25- * which the outbox cron marks the fork's status row failed. A run outliving
26- * that would keep copying under a status that already says it failed; the
27- * remaining five minutes absorb queue wait, since the row starts its clock at
28- * fork time.
25+ * Ends inside {@link STALE_ACTIVE_MS}, after which the outbox cron marks the fork's status
26+ * row failed, so a run never keeps copying under a status that already says it failed. The
27+ * five-minute margin absorbs queue wait, since the row's clock starts at fork time.
2928 */
30- maxDuration : 1500 ,
29+ maxDuration : STALE_ACTIVE_MS / 1000 - 5 * 60 ,
3130 retry : { maxAttempts : 1 } ,
3231 queue : {
3332 name : 'fork-content-copy' ,
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ const BACKGROUND_WORK_PAGE_SIZE_MAX = 100
5353 * sweeps these via {@link reapStaleBackgroundWork}, marking them `failed` so the UI
5454 * surfaces the failure instead of spinning forever.
5555 */
56- const STALE_ACTIVE_MS = 30 * 60 * 1000
56+ export const STALE_ACTIVE_MS = 30 * 60 * 1000
5757
5858/** Terminal rows older than this are pruned by the cron so the audit trail stays bounded. */
5959const RETENTION_MS = 30 * 24 * 60 * 60 * 1000
You can’t perform that action at this time.
0 commit comments