diff --git a/apps/sim/background/knowledge-connector-sync.ts b/apps/sim/background/knowledge-connector-sync.ts index f7ba8e80e4d..ca34b89c62c 100644 --- a/apps/sim/background/knowledge-connector-sync.ts +++ b/apps/sim/background/knowledge-connector-sync.ts @@ -98,7 +98,14 @@ export async function executeConnectorSyncJob(payload: unknown) { export const knowledgeConnectorSync = task({ id: 'knowledge-connector-sync', maxDuration: CONNECTOR_SYNC_MAX_DURATION_SECONDS, - machine: 'large-2x', + /** + * Sized from production telemetry: peak sampled RSS 2.6 GB and peak 1.4 vCPU, + * so `large-1x` holds ~3x memory and ~2.8x CPU headroom. No `outOfMemory` + * escalation: an OOM is a SIGKILL, so the run never reaches the terminal + * write that clears `syncLockToken`, and the escalated attempt would find the + * row still `syncing` and skip. The stale-lock reaper owns that recovery. + */ + machine: 'large-1x', retry: { maxAttempts: 3, factor: 2, diff --git a/apps/sim/background/knowledge-processing.ts b/apps/sim/background/knowledge-processing.ts index 43256bed6d6..8ff7e1aedf2 100644 --- a/apps/sim/background/knowledge-processing.ts +++ b/apps/sim/background/knowledge-processing.ts @@ -135,7 +135,13 @@ export async function runDocumentProcessing( export const processDocument = task({ id: 'knowledge-process-document', maxDuration: envNumber(env.KB_CONFIG_MAX_DURATION, 600), - machine: 'large-1x', // 4 vCPU, 8GB RAM - needed for large PDF processing + /** + * Sized from production telemetry: peak sampled RSS 902 MB and peak 1.2 vCPU + * across a corpus where no document exceeded 2 GB, so `medium-2x` holds ~4x + * memory and ~1.7x CPU headroom over the observed worst case. The prior + * `large-1x` reserved 8 GB against a worst case using an eighth of it. + */ + machine: 'medium-2x', retry: { maxAttempts: envNumber(env.KB_CONFIG_MAX_ATTEMPTS, 3), factor: envNumber(env.KB_CONFIG_RETRY_FACTOR, 2),