Skip to content

fix(knowledge): allow concurrent connector document saves - #7841

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/kb-upload-row-lock
Sep 15, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/kb-upload-row-lock

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Allow connector saves for different documents in one knowledge base to finalize concurrently by checking the active KB under FOR SHARE.
  • Preserve soft-deletion exclusion, connector lease protection, document locks, and upload cleanup. Keep stronger guards on paths that update the KB itself.

Type of Change

  • Bug fix

Testing

  • 22 integration tests passed against isolated PostgreSQL 17.11, including 11 new concurrency tests covering all five guard callers, deletion ordering, same-document updates, lease reclaim, and embedding foreign-key locks.
  • Confirmed the new concurrent-add test fails with the original exclusive guard.
  • 36 focused unit tests and the Sim app type check passed.
  • Repository lint, audits, block-registry check, and docs-manifest check passed.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 15, 2026 2:08am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the weaker lock enables the intended concurrency while preserving the reviewed deletion and persistence invariants.

Summary

This PR replaces the exclusive knowledge-base lock used by connector persistence with a shared row lock, allowing independent document saves to overlap while retaining deletion and lease protection.

  • Uses FOR SHARE while checking that the knowledge base remains active.
  • Preserves connector lease and per-document locking.
  • Adds PostgreSQL integration coverage for concurrent saves, deletion ordering, same-document serialization, lease reclamation, and embedding foreign-key checks.

Diagram

sequenceDiagram
  participant S1 as Document save A
  participant KB as Knowledge base row
  participant S2 as Document save B
  participant D as Knowledge-base deletion
  S1->>KB: SELECT active FOR SHARE
  S2->>KB: SELECT active FOR SHARE
  Note over S1,S2: Shared locks permit independent saves
  S1->>S1: Lock and write document A
  S2->>S2: Lock and write document B
  D->>KB: FOR NO KEY UPDATE
  Note over D,KB: Deletion waits for both saves to commit
  S1-->>KB: Commit and release
  S2-->>KB: Commit and release
  D->>D: Soft-delete KB and archive documents
Loading

Reviews (1) · Last reviewed commit: "fix(knowledge): allow concurrent connect..."

@waleedlatif1
waleedlatif1 merged commit 84727a8 into staging Sep 15, 2026
33 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/kb-upload-row-lock branch September 15, 2026 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants