Skip to content

fix(sidebar): key routine, trigger, type and schema fetches by scope - #2615

Merged
datlechin merged 1 commit into
mainfrom
fix/schema-service-scope-dedup
Sep 3, 2026
Merged

datlechin merged 1 commit into
mainfrom
fix/schema-service-scope-dedup

Conversation

@datlechin

Copy link
Copy Markdown
Member

Root cause

SchemaService shares one in-flight fetch per key so two windows on the same connection do not run the same catalog query twice. The tables fetch was keyed by connection and scope (LoadKey), but the routine, trigger, type and schema fetches were keyed by connection alone. A load for the database being entered therefore joined the in-flight fetch of the database being left, took its answer, and committed that database's routines, triggers and types under the new scope. The stale load is discarded by the generation check, but the joined result is not stale from the new load's point of view: it simply came from the wrong database. Found as a collateral item while working on #2484.

Fix

  • Every object-kind dedup is keyed by LoadKey (connection + scope), the same key the tables fetch already used.
  • reloadRoutines, reloadTriggers and reloadUserDefinedTypes take the scope they refresh, so a targeted reload shares a fetch only with a load of the same scope. The schema-switch refresh passes the scope it already resolved; the coordinator's refresh actions and the enum label editor pass the browse scope, which is the scope the driver they use is on.
  • Cancellation on disconnect and prepareForReload cancels every key of the connection, whatever its scope.

Tests

SchemaServiceRoutinesTests: a new case starts a load for one scope, blocks its routine fetch, starts a load for another scope, and asserts a second routine fetch is issued and the second scope wins. It fails on main, where the count stays at one. The four SchemaService suites pass (34 cases).

Changelog

Fixed: Sidebar routines, triggers and types from the previous database after switching while it was still loading.

https://claude.ai/code/session_014THhVdsUjbCboxNLnQB1dR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin
datlechin merged commit b763e6b into main Sep 3, 2026
8 checks passed
@datlechin
datlechin deleted the fix/schema-service-scope-dedup branch September 5, 2026 06:09
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.

1 participant