Repository navigation
fix(platform): let an upload outrank a sync backlog when indexing - #3217
Merged
Merged
Conversation
A background source that mints index jobs faster than they drain puts every interactive upload behind it. On 0.4 that happened by holding a shared per-org cap of 3 — an integration minting one row every 5 minutes stalled all user uploads on a deployment for 7 days (#2985). The cap is gone with Convex, but `rag.index_file` is still ONE queue for every source, and pg-boss fetches `priority DESC, created_on`, so the backlog is simply ahead. Neither is a bug in the source. The queue was undifferentiated. The five doors where a person is waiting for THAT file now enqueue at `PRIORITY_INTERACTIVE` — upload, hub create, retry (app and REST), and a version replacement. The seven background sources keep the default: OneDrive sync, the crawler's knowledge entries, video links, WebDAV's folder-move fixup, an agent writing a file, and the post-rebuild requeue. One level is enough. `created_on` stays the tiebreak, so interactive work is still fair among itself, and the backlog still drains whenever nobody is waiting — no reserved slot, no second queue, no starved sources. ## Tests The fix is one field per call site, which makes it exactly what a new call site forgets, so the split is asserted from the source. | Mutation | Went red | | --- | --- | | drop the priority from the upload door | `prioritizes every door a person waits at` | | give OneDrive sync the interactive priority | `leaves every background source unprioritized` | | set the level to 0 | `is a positive level, so it outranks an unset background job` | The second direction matters as much as the first: a background enqueue that claimed the priority would put a sync backlog level with an upload again. Refs #2987.
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.
Closes #2987.
A background source that mints index jobs faster than they drain puts every
interactive upload behind it.
The mechanism changed; the starvation didn't
The issue was filed against 0.4, where a shared per-org cap of 3 was held
permanently by whatever produced rows fastest — an integration minting one row
every 5 minutes stalled all user uploads on a deployment for 7 days (#2985).
That cap died with Convex. But
rag.index_fileis still one queue for everysource, and pg-boss fetches
ORDER BY priority DESC, created_on, so abacklog is simply ahead of the person. Same outcome, one less counter.
Neither is a bug in the source. The queue was undifferentiated, which is what
the issue actually said.
The fix the issue suggested
pg-boss takes a
priority, andaddJobInTxalready threaded it — noproduction caller had used it. The five doors where a person is waiting for
that file now pass
PRIORITY_INTERACTIVE:createDocumentFromUpload)createHubDocument)bindReplacement)One level is enough.
created_onstays the tiebreak, so interactive work isstill fair oldest-first among itself, and the backlog still drains whenever
nobody is waiting. No reserved slot, no second queue, no starved sources.
I confirmed the ordering from pg-boss's own plan —
ORDER BY ${priority ? 'j.priority desc, ' : ''}${orderByCreatedOn ? 'j.created_on, ' : ''}j.id, withpriority = trueits default — and thatstartWorkerdoes not disable it.Without that the field would have been inert.
Verification
The fix is one field per call site, which makes it exactly what a new call site
forgets, so the split is asserted from the source rather than from the five
files I happened to edit.
prioritizes every door a person waits atleaves every background source unprioritizedis a positive level, so it outranks an unset background jobThe second direction matters as much as the first: a background enqueue that
claimed the priority would put a sync backlog level with an upload again, and
nothing else would notice.
Gate
typecheck0 errors,oxlint --type-awareclean,oxfmt --checkclean,jobs + documents suites 49 passed (6 files).