fix(cleanupFailedJobs): delete orphaned pending jobs in addition to failed ones#561
fix(cleanupFailedJobs): delete orphaned pending jobs in addition to failed ones#561kelvinkipruto merged 4 commits intomainfrom
Conversation
…ailed ones Previously, the cleanup task only removed failed jobs older than the retention window. This left orphaned pending jobs (never attempted, not scheduled, and older than retention) to accumulate indefinitely, especially in unused queues like "default". Now the task also deletes these orphaned jobs, using parallel counting and deletion for efficiency. The output now distinguishes between deleted failed and deleted orphaned job counts.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@claude Review |
|
Claude finished @kelvinkipruto's task in 1m 37s —— View job Code Review
Overall the change is well-structured and the logic is sound. A few things worth noting: CorrectnessThe
This is a correct and safe set of conditions. A job with a future Issues1. Short-circuit await Promise.all([
failedCount && payload.delete(...), // evaluates to `0` when falsy
orphanedCount && payload.delete(...), // evaluates to `0` when falsy
]);When const deleteOps = [];
if (failedCount) deleteOps.push(payload.delete({ collection: "payload-jobs", where: failedWhere, overrideAccess: true }));
if (orphanedCount) deleteOps.push(payload.delete({ collection: "payload-jobs", where: orphanedWhere, overrideAccess: true }));
await Promise.all(deleteOps);2. Breaking change in output shape ( The output changed from Minor Notes
Summary: The core logic is correct and the parallel count + delete approach is a good pattern. The main actionable items are the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af1f771996
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add uploadError field to extraction objects to store permanent failure reasons. Extractions with uploadError set are excluded from upload retries and marked as permanently failed in the admin UI. Update completion logic to handle mixed success/failure states and provide detailed status in Airtable.
|
@claude Review |
|
@codex Review |
|
Claude finished @kelvinkipruto's task in 1m 48s —— View job Code Review
This PR touches two independent concerns: (1) orphaned job cleanup in
|
| Issue | Severity | File |
|---|---|---|
| Orphaned job deletion not scoped by queue | High | cleanupFailedJobs.ts:41 |
| All-failed case shows misleading "Uploaded to Meedan" status | Medium | uploadToMeedan.ts:590 |
setDocumentFailedStatus removal changes Airtable failure visibility |
Medium (product decision) | uploadToMeedan.ts:575 |
Output shape deleted → deletedFailed/deletedOrphaned breaks consumers |
Low | cleanupFailedJobs.ts:93 |
The most critical item to address before merge is the queue-scoping of orphaned job deletion — without it, any active queue that's down for more than 24 hours will have its jobs silently deleted.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc0ab211b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…tatus When a document has no extractions to upload, calculate a more accurate status message based on existing failures. Also, fetch a fresh document before updating extraction errors to avoid overwriting concurrent updates from other loop iterations.
Description
Previously, the cleanup task only removed failed jobs older than the retention window. This left orphaned pending jobs (never attempted, not scheduled, and older than retention) to accumulate indefinitely, especially in unused queues like "default".
Now the task also deletes these orphaned jobs, using parallel counting and deletion for efficiency. The output now distinguishes between deleted failed and deleted orphaned job counts.
Fixes # (issue)
Type of change
Screenshots
Checklist: