Repository navigation
fix(schema): one cache, keyed by connection, and DDL that names its database (#288, #289, #290) - #640
Merged
Merged
Conversation
…atabase Three schema findings with one shape: state that did not say which server it was about. #290 — the DDL reads ran `USE <database>` and then an unqualified `SHOW CREATE`, as two statements against a pool. With `pool_max > 1` the second is not guaranteed to land on the session the first one changed, so it either failed with "no database selected" or returned the object of that name from whichever database that connection happened to be pointing at. Silently, and only sometimes. The `USE` error was discarded with `let _ =`, so the cause never surfaced either. All four now name `` `db`.`object` `` and run one statement. Verified on MySQL 8.0.46 and MariaDB 11 for tables, views, procedures, functions and triggers. The identifiers are quoted properly on the way in. A name reaching the inspector comes from the schema rather than a text box, so this is a second line rather than the first — but a table can be named anything, and a name read back from information_schema is not thereby safe to splice into SQL. The SQL export had the same gap, where it produced statements that do not parse. #288 — the tree kept its schema in component state keyed only by database name. `mysql` and `app` are on nearly every server, so two connections showed each other's objects and a context-menu action ran against whichever server the tree had been built from. A response arriving after a switch repopulated the new tree with the old server's tables. #289 — refreshing had the matching problem. A database-level refresh reloaded only tables, leaving views, routines and triggers as they were when the node first opened. The toolbar's full refresh cleared a *different* cache that the tree never read, so the tree stayed stale while the autocomplete updated, and a refresh from the tree did the opposite. Both are one store now, keyed by connection, with a generation counter per connection: a fetch captures it before awaiting and drops its result if it no longer matches. Invalidation is scoped — a folder, a database and all its folders, or the whole connection — and the autocomplete reads the same store rather than keeping a second copy of the same objects, so `schemaCacheStore` is gone. Disconnecting forgets what was known, which also stops the cache growing by one server per session. Two things the work turned up: generations have to live outside the store, or forgetting a connection resets them to zero — which is what an in-flight fetch captured, so a response landing after a disconnect matched and was applied. And a selector returning a fresh empty object for an unknown connection re-renders the tree forever. Co-Authored-By: Claude Opus 5 <[email protected]>
EVWorth
force-pushed
the
fix/schema-connection-scoping
branch
from
September 11, 2026 22:15
b0f2737 to
7b6cf5c
Compare
…tore `scripts/check-test-mocks.sh` caught these in CI, which is what it is for: Vitest ignores a `vi.mock` whose path resolves to nothing, so both files were quietly running against the real module. Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Sep 11, 2026
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.
Three schema findings with one shape: state that didn't say which server it was about.
#290 — DDL could read the wrong database
The DDL reads ran
USE <database>and then an unqualifiedSHOW CREATE, as two statements against a pool. Withpool_max > 1the second isn't guaranteed to land on the session the first one changed, so it either failed with "no database selected" or returned the object of that name from whichever database that connection happened to be pointing at. Silently, and only sometimes. TheUSEerror was discarded withlet _ =, so the cause never surfaced either.All four reads now name
`db`.`object`and run one statement. Verified on MySQL 8.0.46 and MariaDB 11 for tables, views, procedures, functions and triggers.The identifiers are quoted properly on the way in. A name reaching the inspector comes from the schema rather than a text box, so this is a second line rather than the first — but a table can be named anything, and a name read back from
information_schemaisn't thereby safe to splice into SQL. The SQL export had the same gap, where it produced statements that don't parse.#288 — connections shared a cache
The tree kept its schema in component state keyed only by database name.
mysqlandappare on nearly every server, so two connections showed each other's objects and a context-menu action ran against whichever server the tree had been built from. A response arriving after a switch repopulated the new tree with the old server's tables.#289 — refresh reached the wrong cache
A database-level refresh reloaded only tables, leaving views, routines and triggers as they were when the node first opened. The toolbar's full refresh cleared a different cache that the tree never read — so the tree stayed stale while the autocomplete updated, and a refresh from the tree did the opposite.
One store
Both are one store now, keyed by connection, with a generation counter per connection: a fetch captures it before awaiting and drops its result if it no longer matches. Invalidation is scoped — a folder, a database and all its folders, or the whole connection — and the autocomplete reads the same store rather than keeping a second copy of the same objects, so
schemaCacheStoreis deleted. Disconnecting forgets what was known, which also stops the cache growing by one server per session.Two things the work turned up:
Verification
2541 unit + 341 browser tests. 23 new store tests, 4 new tree tests, 4 live-server Rust tests. The Rust tests fail against the old
USE-then-SHOWcode (2 of 4 reproduce it directly); the tree tests fail against both a shared cache and shared expansion state.Closes #288
Closes #289
Closes #290
🤖 Generated with Claude Code