Repository navigation
fix(folders): run reorder lock checks on the reorder transaction - #9055
Merged
Merged
Conversation
The folder reorder route checked folder locks inside its transaction but through the global pool, checking out a second connection while the transaction held one. assertFolderMutable now takes an optional executor and the route passes its transaction handle, so the ancestry walk reads on the held connection and under the folder-tree advisory lock.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The PR appears safe to merge; folder lock checks now use the reorder transaction without changing existing callers. SummaryFolder reorder now checks folder locks using the connection its transaction already holds.
|
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
PUT /api/folders/reorderranassertFolderMutableinside itswithTransactionRetrycallback, but the lock walk queried the global pool. Each check took a second connection while the transaction held one, which can deadlock the pool at saturation (the@sim/dbtransaction tripwire flags exactly this)assertFolderMutablenow accepts an optionalexecutor(the samePick<typeof db, 'select'> = dbshaperesolveEffectiveWorkspacePermissionuses). The reorder route passes itstx, so the ancestry walk reads on the held connectionupdateFolder(lock toggles) also takesassertFolderMutable/assertWorkflowMutableruns inside a transaction. They all check before opening one, and the default executor leaves them unchanged@sim/dbglobally, so the real pool instrumentation never ran. The new integration test runs the route against real Postgres with the tripwire inthrowmode. All 3 cases fail with 500 before the fix and pass afterType of Change
Testing
New
app/api/folders/reorder/route.integration.tscovers three cases against real Postgres (tripwirethrow): reparent + reorder of unlocked folders, a folder that inherits its ancestor's lock (423), and a locked destination (423). I confirmed it fails on the pre-fix code and passes with the fix.Checklist