fix(plugin-snowflake): key the shared session on the saved connection and scope Stop to its own driver - #2470
Merged
datlechin merged 1 commit intoAug 26, 2026
Conversation
… and scope Stop to its own driver Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
datlechin
added a commit
that referenced
this pull request
Aug 26, 2026
…dpoint sends (#2466) * fix(plugin-snowflake): decode the wire encodings the query-request endpoint sends Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): give every statement builder one SQL escaper (#2467) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): keep a timestamp offset the date parser cannot represent as text (#2468) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): take the affected row count from the statement type, not a column name (#2469) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 * fix(plugin-snowflake): key the shared session on the saved connection and scope Stop to its own driver (#2470) Claude-Session: https://claude.ai/code/session_01Qk1xfY3vnneRifC22eV2r7 --------- Co-authored-by: Ngo Quoc Dat <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.
Found while investigating #2454. Two defects with one cause: several drivers share one Snowflake session, and nothing said which driver a session or a running statement belonged to.
One session for two connections
SnowflakeConnectionRegistryhands out a sharedSnowflakeConnectionkeyed onsessionFingerprint, which was:That names the account, not the connection. Two saved connections to the same account, user and role, one defaulting to
PRODand one toSTAGING, got the same session. Opening the second showed the first's objects, switching database in either window moved the other window's current database, and a grid save in the untouched window then wrote to the database it was never pointed at.The key now includes the saved connection's own identifier, which the app passes through
additionalFields.The database cannot be used for this, which is the whole reason a new identifier was needed.
MetadataConnectionPool.openEntrycopies the connection and rewritesconnection.databaseto whatever database the metadata read targets, then builds a driver from that copy. A key that varied with the database would give the pooled driver a different key, a second login, and another MFA prompt, which is exactly what sharing the session exists to avoid. The connection's identifier survives that rewrite because the pool copies the connection rather than fabricating one.Stop cancelled everybody's work
cancelQuery()calledcancelAllQueries(), which aborted every request id on the session:Since the session is shared by the driver the user sees and by every pooled metadata driver behind it, pressing Stop on a long query also aborted a sidebar schema refresh running beside it, which then reported the schema as unloadable. It cut both ways: stopping any query killed a save's remaining statements mid-batch.
Each driver now carries its own owner token, the connection tracks request ids per owner, and
cancelQueries(owner:)aborts only that driver's statements. Statements the connection issues for itself, such as the connect-timeUSEcalls, belong tosessionOwnerand are never the target of a Stop.This matches
DatabaseDriver.cancelQuery's contract, which is about the currently running query, not the connection.Tests
SnowflakeSessionKeyTests, 6 cases: two saved connections to one account do not share, the same connection always resolves to one session, the database is not part of the key, account identity still separates sessions on host, user, auth method and role, and user and role compare case insensitively.The per-owner cancellation is structural rather than unit tested: the tracking lives on the shared connection behind its lock, and a test for it would restate the dictionary rather than pin behaviour.
Verified: build PASS, 48/48 across this and the neighbouring Snowflake suites, SwiftLint 0 violations across 5238 files.
Note on scope
This touches one app file,
DatabaseDriver.swift, to passconnectionIdinadditionalFields. That is deliberately not aDriverConnectionConfigchange: adding a field there would alter shared PluginKit ABI for all 32 plugins, andadditionalFieldsalready exists for exactly this. No ABI change, no version bump.