fix(coordinator): run structure and trigger edits on a connection of their own - #2616
Merged
Conversation
…their own instead of the session driver Claude-Session: https://claude.ai/code/session_014THhVdsUjbCboxNLnQB1dR
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
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.
Root cause
A structure save and a trigger edit both wrap their DDL in a
BEGINand aCOMMITof their own, and both ran on the session driver: the structure save throughexecutionRoute, the trigger editor straight throughdriver(for:)with no scope, no pin and no gate at all. The session driver is also the connection a query tab runs on, so when that tab had a transaction open, the edit'sBEGINjoined it (PostgreSQL only warns), itsCOMMITcommitted the tab's uncommitted rows along with the DDL, and a failed statement'sROLLBACKthrew the tab's work away. MySQL commits implicitly on DDL, so there the tab's transaction was committed without any message at all. Found as a collateral item while working on #2484; the enum label editor from that PR already took the pooled route for the same reason.Fix
DatabaseManager.schemaChangeRoute(for:)names the rule: the app's own DDL runs on a pooled connection wherever the engine can open one, and on the session driver only where nothing else can (DuckDB, PGlite and any engine whose second connection would not reach the same database). It is the metadata route under a name that says why.DatabaseScopeand run throughwithScopedDriverwith the.protectedWritepolicy, so a Stop cannot cut a half-applied trigger edit and the DDL lands on the tab's database rather than wherever the session driver happens to be. The definition fetch for Edit goes through the metadata route as well.Behaviour change worth knowing
A save that used to join an open transaction on PostgreSQL now waits for that transaction's lock on the table until the connection's query timeout, then fails with the server's timeout error. That is the honest outcome; the old one committed the user's work silently.
Tests
DatabaseManagerSchemaChangeRoutingTests: rewritten around a pooled fake seeded intoMetadataConnectionPool(a DEBUG-onlyinjectEntry, the pool's counterpart toinjectSession). Every pooling case asserts the session driver ran nothing and was never switched; the pin tests use a registered single-connection type so the session-driver path is still covered; a new case pins the route choice for pooling, single-connection and server-scoped scopes.TriggerApplyExecutionTests: apply and drop run on the pooled stub, in transaction order, and the session stub sees nothing.No UI test: the flow needs a live server with a second connection.
Docs and changelog
docs/features/table-structure.mdxsays a save and a trigger change run on their own connection.Fixed: Structure and trigger edits committing or rolling back a transaction left open in a query tab on the same connection.
https://claude.ai/code/session_014THhVdsUjbCboxNLnQB1dR