fix(knowledge): stop recovery from re-dispatching documents whose runs are still queued - #7992
Closed
waleedlatif1 wants to merge 2 commits into
Closed
waleedlatif1 wants to merge 2 commits into
waleedlatif1 wants to merge 2 commits into
Conversation
…s are still queued
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
Contributor
There was a problem hiding this comment.
1 issue found across 15 files
Confidence score: 4/5
apps/sim/lib/knowledge/__integration__/connector-lifecycle-locks.integration.tsdoes not verify replacement generation or its charge because the mockedprocessDocumentsWithQueueperforms no database write, leaving the lifecycle behavior insufficiently covered; exercise the real queue path or use a DB-aware mock and assert the persisted replacement and charge.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/knowledge/__integration__/connector-lifecycle-locks.integration.ts">
<violation number="1" location="apps/sim/lib/knowledge/__integration__/connector-lifecycle-locks.integration.ts:284">
P2: This test never verifies the replacement generation or its charge because `processDocumentsWithQueue` is mocked to perform no database write. Run this case through the real queue path, or use a DB-aware mock and assert the replacement token/outbox record and final attempt count.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…ker-reached charges
Collaborator
Author
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pendingdocument older than the 4h queue grace as a lost dispatch and installs a new generation plus a new run. A queue has no bound on wait time (Trigger.dev keeps an unstarted run for 14 days), so when the backlog grew past the grace, recovery re-dispatched documents whose original run was still queued. The replacement joined the same backlog, and each sweep added another run per waiting document.pendingwithout being processed once.knowledge-process-documentdispatch (batch dispatch, recovery relay, quota/provider continuations) now gets a Trigger.devttl. It expires the run at its generation's queue stamp +QUEUED_DISPATCH_START_DEADLINE_MS(grace − 30 min). By the time recovery can replace a generation, its run can no longer start, so each document has at most one startable run. The deadline comes from the stamp, so a late outbox relay only gets the time its generation has left, and a delayed run's TTL is counted from the end of its delay.pending, stamped, not deferred, past grace) no longer charges a second attempt. Its unused charge moves to the replacement, applied the same way in recovery, the connector sweep, and a user retry viareleaseUnclaimedDispatchAttempt.deleted_at IS NOT NULL). Before, every page rewrotedeleted_at = NULLon every verified live document.persistDocumentAclsas is.acl_verified_athas to be refreshed every admin sync, so the row is written anyway, and becauseacl_verified_atisn't indexed and an unchangedaclkeeps the update HOT-eligible, skipping theaclcolumn would save nothing measurable.Type of Change
Testing
MAX_PROCESSING_ATTEMPTSwithout spending budget, and is then indexed exactly once while the superseded generations no-op.bun run type-check, lint,check:api-validation, andcheck:auditsall pass.Checklist