Repository navigation
Intake jobs are claimed before model work, so a sync no longer waits behind the extraction backlog - #1324
Merged
WaylandYang merged 2 commits intoOct 19, 2026
Conversation
QuintinBotes
force-pushed
the
fix/intake-before-model-work
branch
from
October 19, 2026 18:22
17ccfe6 to
4cbf095
Compare
…behind the extraction backlog Signed-off-by: Quintin Botes <quintinbotes@outlook.com>
QuintinBotes
force-pushed
the
fix/intake-before-model-work
branch
from
October 19, 2026 18:29
4cbf095 to
6d25a6d
Compare
WaylandYang
approved these changes
Oct 19, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thank you, Quintin. This is exactly the shape we discussed in #1300, and the description made it easy to review. Using an IMMUTABLE function with an expression index instead of a stored column is a good call: same order, same index, without rewriting all of jobs at startup, and the migration comment tells the next person how to change the list. All eight kinds check out against dispatch (none makes a chat call), and the claim test is well isolated and fails without the ORDER BY change. #1300 stays open for the reserved lane. Merging.
gedaiu
added a commit
to re-cinq/utopia
that referenced
this pull request
Oct 19, 2026
Brings in deeplethe#1324 (intake jobs are claimed before model work) and deeplethe#1325 (a base can follow a GitHub repository's markdown files). CURRENT_SCHEMA_VERSION is recounted to 107 for upstream's 0116. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
5 tasks done
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.
Part of #1300: the claim order. The reserved lane follows as its own PR, as agreed there.
Why
claim_oneordered only byrun_at, so every kind waited in one queue. While hundreds of documents wait for extraction, the hourlysync_sourceand theprocess_documentjobs for newly synced files wait behind every olderextract_document. On a local model that was days: a source went unsynced for ten hours, and 423 new documents stayed pending and unsearchable.What changes
job_priority(kind). It returns 0 for the kinds that make no chat call and 1 for the rest. Those kinds aresync_source,process_document,hydrate_rss_entry,embed_ontology,memory_ingest,build_vector_index,materialize_inferencesandnoop: the list from A sync or a new document waits behind the whole extraction backlog: jobs are claimed strictly by run_at #1300, withmemory_ingestadded as you suggested. The priority comes fromkind, so no enqueue site changes. It also adds the indexjobs_priority_claim_idxon(job_priority(kind), run_at) WHERE status = 'queued'.claim_oneorders byjob_priority(kind), run_at. With an emptyjobstable andenable_seqscanoff,EXPLAINof the claim query shows an index scan on the new index and no sort node.prioritycolumn. A stored column would rewrite all ofjobs, finished jobs included, during the startup migration. AnIMMUTABLEfunction with an expression index gives the same order and index without that. The list lives only in the function, and the migration's comment says how to change it:CREATE OR REPLACEin a new migration and rebuild the index.CURRENT_SCHEMA_VERSIONis 104, the number of files inmigrations/.jobs_claim_tests.rschecks that async_sourcequeued later is claimed before an earlierextract_document. Both rows are dated a century back, soclaim_onetakes them before anything else in the database, and the test deletes them afterwards. Without theORDER BYchange it fails withleft: Some("extract_document").#1316 by @linhongyu510 takes the same approach in
claim_one; this PR adds the index and the claim test discussed in #1300.How it was checked
On an M1 Max (macOS), at the PR head on top of
dev0daaed0:cargo fmt --all --check: passes.cargo clippy --workspace --all-targets -- -D warnings: no issues.cargo test --workspace --no-fail-fastwithUTOPIA_DATABASE_URLpointing at a database created and migrated for this branch alone: 1,641 passed, 0 failed, 6 ignored.UTOPIA_TEST_REQUIRE_DB=1: it passes, and fails without theORDER BYchange.Before review
git commit -s)cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepasscrates/utopia-store/was tested withUTOPIA_DATABASE_URLset (those tests skip without it)dev, andCURRENT_SCHEMA_VERSIONincrates/utopia-cli/src/main.rsequals the number of files inmigrations/