You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3a57638
Browse filesBrowse the repository at this point in the historyBrowse files
fix(file-search): claim a file write that lands on an owner the backfill already queued
Backfill reconciliation wake-ups enter the owner queue as if just dispatched so they rotate in
behind owners woken for a write. A write that landed while such a row was still queued only
advanced its updated_at through the file trigger's upsert, so it kept the reconciliation stamp
and waited behind every older-stamped owner. The same held for an owner that was served, left
queued with work, and then woken again.
Claims now take owners woken since their last dispatch first: never dispatched, or updated_at
later than last_dispatched_at, which every real wake-up (file write, released claim, reaped claim,
artifact-ready requeue) advances and a reconciliation wake-up never does; it no longer touches an
owner already queued. Within each group the dispatch-age rotation is unchanged. Queue timestamps
the comparison reads come from the transaction clock, the same clock the trigger writes.
Migration `0426_file_search_owner_scope.sql` adds canonical workspace/Project ownership to the existing build, revision, and chunk pipeline. Legacy workspace inserts are translated by triggers, and the existing workspace trigram index remains usable. Project rows use a separate owner-scoped trigram index on the same chunk table. Organizations and personal users are not enabled search owners.
73
73
74
-
The new `file_search_dispatch_queue` replaces the workspace-keyed scheduler because older workers cannot decode a Project without a workspace. During expansion, workspace mutations enqueue both queues, while the new dispatcher reads the owner queue. Both deployments share the dispatcher lock, revision claim token, build lease, and publication fence. Drain old app dispatchers and Trigger workers/retries before enabling Project dispatch. Retire the legacy queue and its dual enqueue in a later contract deploy; they are not a second indexing pipeline. The `file-search-owners-v3` cursor performs bounded owner/file keyset backfill and hourly reconciliation without rewriting extracted text in the migration. Each claim pass takes owners never dispatched first, so the owners a backfill page wakes enter the queue as if just dispatched: a page of reconciliation wake-ups rotates in by dispatch age behind the owners the file trigger woke for a write, instead of delaying them by several passes.
74
+
The new `file_search_dispatch_queue` replaces the workspace-keyed scheduler because older workers cannot decode a Project without a workspace. During expansion, workspace mutations enqueue both queues, while the new dispatcher reads the owner queue. Both deployments share the dispatcher lock, revision claim token, build lease, and publication fence. Drain old app dispatchers and Trigger workers/retries before enabling Project dispatch. Retire the legacy queue and its dual enqueue in a later contract deploy; they are not a second indexing pipeline. The `file-search-owners-v3` cursor performs bounded owner/file keyset backfill and hourly reconciliation without rewriting extracted text in the migration. Claims take owners woken since their last dispatch first (`wokenSinceDispatch` in `dispatcher.ts`); backfill wake-ups enter as if just dispatched and never touch an owner already queued, so a page of them cannot delay a file write by several passes.
75
75
76
76
Generated document indexing never executes source. A cached artifact must match its owner and current input manifest. Each published build stores at most 500 input identities. Queries exclude a build when any input is changed, archived, deleted, or outside the owner, and report it as pending coverage. Input mutations wake their owner queue; the dispatcher retires stale manifests in bounded batches before rebuilding. Expired build cleanup also removes its dependency records. A cache miss indexes the stored generation source as text until an authorized rendering path creates a current artifact.
* The transaction's start time. Queue rows compare `updated_at` with `last_dispatched_at`, and
176
+
* the `workspace_file_search_mark_pending` trigger writes `updated_at` the same way, so both sides
177
+
* share one clock.
178
+
*/
179
+
consttransactionNow=sql`now()`
180
+
181
+
/**
182
+
* Whether an owner was woken after its last dispatch: never dispatched, or touched since. A file
183
+
* write, a released claim, and a reaped claim advance `updated_at`; a claim stamps both columns
184
+
* with one time, and a reconciliation wake-up enters with them equal. A write whose transaction
185
+
* began before the claim that stamped its owner reads as earlier and waits one rotation.
186
+
*/
187
+
constwokenSinceDispatch=sql`(${fileSearchDispatchQueue.lastDispatchedAt} IS NULL OR ${fileSearchDispatchQueue.updatedAt} > ${fileSearchDispatchQueue.lastDispatchedAt})`
188
+
174
189
/**
175
190
* Queues owners for the claim pass. A `reconciliation` wake-up, from the backfill walk, enters as
176
-
* if just dispatched: claims take owners never dispatched first, so marking it served keeps a page
177
-
* of owners with nothing new behind the owners the file trigger woke for a write, and its row still
178
-
* rotates in by dispatch age. An owner already queued keeps its place either way.
191
+
* if just dispatched and never touches an owner already queued, so a page of owners with nothing
192
+
* new rotates in behind the owners woken for work.
179
193
*/
180
194
asyncfunctionenqueueOwners(
181
195
tx: DbTransaction,
@@ -185,20 +199,18 @@ async function enqueueOwners(
0 commit comments