fix: schema-graph drawer stale-write race, cancellation, progressive draw (#124)#125
Merged
Merged
Conversation
…draw (#124) Fixes the same-class-as-#97 stale-write race in the inline schema-lineage drawer via a request-identity guard, adds AbortController-based cancellation with a working Cancel affordance, and draws large schemas progressively (free edges immediately, view/MV source edges once EXPLAIN AST settles) to avoid a blank pane on the round trip — gated below AST_PROGRESSIVE_THRESHOLD so small schemas still draw in one step, no flicker. Expanding a closed db row now also draws its graph, matching drag-to-drawer. Closes #124 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01784dKCpk5W7rdpUAwcQnix
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.
What & why
Fixes #124: the inline schema-lineage graph (drag/click a db/table onto the
results pane) had a stale-write race, no cancellation, and no progressive
draw — a slow schema left the pane blank for the whole round trip with no way
to stop it.
showSchemaGraphnow captures arequest-identity token and checks it before every write, so a Run/Explain
or a second graph request that replaces the tab's result mid-fetch can
never have a superseded fetch's resolution land on the wrong result.
Covered by regression tests reproducing the race for both
run()andrunScript(), plus a last-triggered-wins test for two rapid graph requests.app.state.schemaGraphAbortController+ acancelSchemaGraph({clearResult})helper — auto-cancel on Run/Explain/a newgraph request, and a manual Cancel button (mirrors the existing
.exp-cancelexport-progress pattern) on both the pre-draw placeholder andthe in-progress toolbar. Cancelling keeps an already-drawn free-edges graph
on screen (marked partial) or falls back to the empty-results placeholder,
whichever has something to show.
tryQueryDatanow rethrows a genuinecancellation (gated on the caller's own
signal.aborted) instead ofsilently degrading
system.dictionariesto "no dictionaries, continue".loadSchemaLineagefires anonBasecallback with the free edges (dependencies/target/engine-arg/dictionary —
no extra round trip) as soon as they're known, then a single second layout
merges in the view/MV source edges once
EXPLAIN ASTsettles, with a"resolving N/M…" toolbar readout. Below
AST_PROGRESSIVE_THRESHOLD(50)view/MV objects the two-phase split is skipped entirely — the whole fetch
settles fast enough on a small schema that a visible first paint is just
flicker, not a win.
schema graph (matching drag-to-drawer); collapsing again doesn't re-fetch
or re-draw.
Verified live against a real ClickHouse server (see PR description checklist
below) — progressive draw, the race fix, and both cancel paths all confirmed
end-to-end, including a tab-switch probe.
Checklist
npm testpasses (the per-file coverage gate is non-negotiable)npm run buildsucceeds (single-filedist/sql.html)src/core/, network insrc/net/(injected fetch), DOM insrc/ui/CHANGELOG.md([Unreleased]) updatedCo-Authored-By: Claude Sonnet 5 noreply@anthropic.com
https://claude.ai/code/session_01784dKCpk5W7rdpUAwcQnix