Repository navigation
improvement(db): disable embedding FTS fastupdate and index delete-action foreign keys - #8943
Conversation
…tion foreign keys Inserts into embedding could stall for seconds merging the shared GIN pending list in the foreground, while holding the document row lock. Turn fastupdate off (the 0364 pattern) and drain the existing list once. User and workspace deletion ran sequential scans for four referential actions inside the deleting transaction, holding row locks other writers queued behind. Add concurrent indexes backing document.uploaded_by, user_table_rows.created_by, user_table_definitions.created_by and execution_large_values.workspace_id.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Turn on auto-fix | Re-trigger cubic
|
Summary
emb_content_fts_idx:SET (fastupdate = off), then a boundedgin_clean_pending_listdrain. This is the 0364 / fix(file-search): avoid foreground GIN cleanup stalls #7995 pattern. With fastupdate on, the insert that pushes the shared pending list pastgin_pending_list_limitmerges the whole list into the index in the foreground (ginInsertCleanupwithwork_mem). It does this while holding the documentFOR UPDATErow lock. A 2-row chunk insert took 8.6s and the slowest insert this week took 53s, with no lock waits logged for those statements.document.uploaded_by(SET NULL, partialIS NOT NULL): p50 24s per deletionexecution_large_values.workspace_id(CASCADE): p50 21s. Its cleanup indexes lead withworkspace_idbut are partial ondeleted_at, soworkspace_id = $1cannot use them.user_table_rows.created_by(SET NULL, partialIS NOT NULL): p50 10suser_table_definitions.created_by(CASCADE): about 100msschema.tsmirrors all five changes.drizzle-kit generateproduces nothing new after 0410.Side effects
ALTER INDEX ... SET (fastupdate)takesAccessExclusiveLockon the index only (checked inpg_locks; the table is not locked). That still blocks writes toembeddingand planning of queries on it. It is bounded by the 5slock_timeoutplus the time-budgeted retry inmigrate.ts.gin_clean_pending_listtakesRowExclusiveLockand does not conflict with traffic.CREATE INDEX CONCURRENTLYtakesShareUpdateExclusiveLockand waits for older transactions to finish.COMMIT;is idempotent. A second run is a no-opALTER, an empty drain, and drop-and-recreate of only the new indexes (the 0407/0408 convention, which recovers an INVALID build).workspace_file_search_segment_workspace_content_trgm_idx. Nothing in the app inserts into that table anymore, so its write path has no tail to fix.Type of Change
Testing
ALTER INDEXlock level.auto_explainwith nested statements, including withplan_cache_mode = force_generic_plan, to confirm that all four RI action queries (... WHERE $1 = col) use the new indexes, the partial ones included.bunx drizzle-kit generate: no schema changesbun run check:migrations origin/staging: passescheck:schema-mockandcheck:comment-hygiene: passschema.ts: cleanChecklist
test-auditauthoring gate)