fix(knowledge): stop holding the connector table lock across the processing commit - #8191
Conversation
…processing commit
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…nnector locks after the insert
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
SELECT ... FOR UPDATEthat checked the connector with anEXISTSonknowledge_connector. That read heldAccessShareLockonknowledge_connectoruntil commit, through every embedding and search-index write. When index writes are slow (tens of seconds under I/O pressure), a steady stream of these transactions keeps the table locked, andALTER TABLE knowledge_connectorcannot get its lock withinlock_timeoutFOR UPDATEnow reads only the document row. The connector check, plus a new knowledge-base check, runs in the completionUPDATEat the end.knowledge_connectoris now only locked from that statement until commitknowledge_baseis still locked for the whole pass, through theembeddingforeign key and the projection triggers. That is out of scope hereUPDATEnow returns its matched rows. If it matched none, meaning the connector or knowledge base went inactive during the pass, the whole pass rolls back and returnssuperseded. Before this change, the embeddings committed while the document stayedprocessing?w=1. Most of the stat is re-indentation from the.catchon the transactionType of Change
Testing
processing-lock-scope.integration.ts(real Postgres), 5 tests, added to the knowledge integration step intest-build.yml:AFTER INSERTprobe onembedding(fires after the row triggers and FK checks) fails if the backend holds any lock onknowledge_connectorEXISTSin the opening select fails the lock probetype-check, biome, andcheck:auditsChecklist