Repository navigation
fix(projects): fence file writers with a shared Project lock - #9025
Merged
Merged
Conversation
lockWorkspaceProject now takes the Project key shared, so file writers in one Project no longer serialize against each other while exclusive holders (fork, split, archive, payer transfer, departure, account deletion, retention) still fence them. lockWorkspaceProjectExclusive keeps the old semantics for requireForkProject, splitForkProject, and archiveWorkspace. Organization departure takes the departing workspaces' Project locks before rewriting workspace owners, matching the writers' Project -> workspace row -> payer order instead of inverting it. Payer transfer skips zero-byte contributions before the destination payer check, locks Projects in one ordered call instead of one-by-one and twice, and drops the test-only changeWorkspaceStoragePayersInTx entry point.
…tore Their multi-row deleted_at updates fire the search-index trigger, which upserts the dispatch queue row before later file rows are locked. A concurrent content write holds the workspace row and a file row and then waits on that queue row, so the two could deadlock. The exclusive Project lock used to hide this; take the workspace row first, the order every file writer uses.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
Collaborator
Author
|
@greptile |
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
This branch was previously deployed
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.
Summary
Follow-up to #8609, which replaced the per-workspace folder lock on about 15 workspace-file write paths with
lockWorkspaceProject: an exclusive advisory lock on the whole Project (a workspace and all its forks), with a 5s bound that becomes a 409ProjectConflictError. Rename, delete, restore, image-dimension and chat-upload writes previously took no lock. Under #8609, every file write in every environment of a Project serialized, and contention surfaced as random 409s.lockWorkspaceProjectExclusivekeeps today's semantics for fork, split andarchiveWorkspace. I checked every caller, and no transaction upgrades from shared to exclusive.deleted_atupdates upsert the search dispatch queue through the trigger, which deadlocked with a concurrent content write. The exclusive Project lock had been hiding that.changeWorkspaceStoragePayersInTxentry point and its dead branch are removed. Tests now go through the real entry point.Type of Change
Testing
foundation.integration.ts: while one writer holds the shared Project lock, a writer in a sibling environment proceeds immediately (on the old code it hit the 5s timeout), and an exclusive lifecycle holder is still blocked.workspace-file-folder-manager.test.tspasses locally (12/12). Full suites in CI.Checklist