fix(jobs): classify transient database failures once for background retries - #8194
Conversation
…etries - classifyDatabaseFailure in @sim/utils/errors: capacity / conflict / connection / permanent - shared Trigger catchError decision helper with minute-scale database backoff - workspace file search, document processing, connector sync, and the 0021 backfill adopt it - a scheduled document retry leaves the document pending instead of failed - a transient database failure no longer counts toward connector auto-disable
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…ver members mode - connector and members-mode syncs climb the failure ladder by the failed-run streak read from their run logs; database failures never advance the auto-disable counter - classify 25P03 as capacity and ECONNREFUSED/EHOSTUNREACH/ENOTFOUND/EAI_AGAIN (with a query) as connection - in-process document processing keeps recording database failures as failed, documented - offer Retry for a pending document whose dispatch or deferred retry is past the retry API's grace - correct the processing task's retry-ceiling comment
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
…fields Restores the document list, contract, serializer, and Retry condition to staging; Retry stays failed-only.
There was a problem hiding this comment.
All reported issues were addressed across 27 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…try never ran - the deferral write and a deferred-retry-check outbox event commit together for uploaded documents - the check fails the document only if the same deferral is still pending, overdue past the queue grace, and no run is live; otherwise it rechecks without spending an attempt, bounded by the recovery window - a database deferral stamps processingQueuedAt when unset, so a dispatch cannot claim the row as never-queued during the retry window
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 26 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Fix all with cubic | Re-trigger cubic
…se failures A transient database failure while checking postpones the check without spending an attempt, paced by how overdue it is and capped at the recheck interval, until a terminal bound past the recovery window; other errors, and any error past that bound, spend attempts as before.
…al, strict query shapes - the database-failure streak counts only failed runs that made no progress; a run that wrote documents (or completed a member) retries in minutes - ten zero-progress database failures in a row log an alertable error; the connector is never disabled for them - the classifier's query check matches only Drizzle's query error and the postgres.js query error shapes, so a client error carrying its own query stays a source failure
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 26 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Fix all with cubic | Re-trigger cubic
…river connection errors - the connector run-history read runs under short statement and lock timeouts and falls back to this run alone - members-mode progress counts lifecycle purges (docs_purged in the run log) - postgres.js connection codes count only on an error the driver built, or under a query error; the driver's query signature is its four own properties, which a refused connection carries with no SQL yet - real-error PostgreSQL test for terminated transactions, refused connections, and an ending pool, wired into CI - knowledge-processing tests use the static task import
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 28 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Fix all with cubic | Re-trigger cubic
… query as connection failures
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 28 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 28 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Summary
classifyDatabaseFailurein@sim/utils/errorsreturnscapacity(57014 statement timeout, 55P03, 25P03, 25P04, 53300),conflict(40P01, 40001),connection(08xxx, 57P01–57P03, postgres.jsCONNECTION_*/CONNECT_TIMEOUT, and socket codes such asECONNRESET,ECONNREFUSEDorENOTFOUNDonly when Drizzle's query error or a postgres.js query error is in the cause chain, so a client error carrying its ownquerystays a source failure), orpermanent. It walks the cause chain, and a 57014 from an explicit cancellation stayspermanentcatchErrorhelper (lib/core/errors/background-retry.ts): transient database failures back off 2 → 4 → 8 → 16 → 30 min with jitter up to their own attempt ceiling; everything else keeps the task's normal retries and attempt countknowledge-process-document) gets acatchError. On a transient database failure the service writes the document aspendingwithprocessingDeferredUntilset to the scheduled retry, instead offailed, and the task retries at that same time.failedis written only when database retries run out or the error is permanent. So an uploaded document, which no recovery sweep covers, is no longer left failed forever by a slow database window. Connector documents keep their recovery sweep, which still sees apending+ deferred-until row after its grace periodfailed("its scheduled retry did not run") so the user's Retry re-dispatches it; no actor, no re-dispatch, no scan. A live or unknown run is rechecked hourly without spending an attempt, bounded by the recovery window. The deferral also stampsprocessingQueuedAtwhen unset, so a dispatch cannot claim the row as never-queued during the retry windowcause. Trigger records only name, message, and stack, so SQL and bound parameters still never reach itNote: #8195 depends on this PR.
Type of Change
Testing
catchError+ pending/failed status, sync auto-disable exemption throughexecuteSync, 0021 page retries, file search)catchErrorwiring, the service pending write, the sync branch and builder, the 0021 retry gate): every mutation turned its named tests redbun run lint,bun run check:audits(47/47),check:api-validation,type-check(apps/sim, packages/utils, packages/db)Checklist