Expand description
Bounded session pools for concurrent, per-query-context Snowflake access.
On the v1 query endpoint, statement context (warehouse/role/database/
schema) is session-global — changed via USE and shared by every query
on the session token. So a query that needs a specific context must hold its
session exclusively for the USE … + query. To get concurrency and
per-query context without re-authenticating per query, each (account, user)
keeps a bounded pool of up to max authenticated sessions (each a
separate browser auth): a query checks one out, applies any USE needed
(skipping USEs already in effect), runs, and returns it.
- Concurrency is capped at
maxby atokio::sync::Semaphore: a permit is held for the whole checkout, and a new session is created only while holding a permit with no idle session available — so the live-session count (and thus the number of browser auths) never exceedsmax, and grows lazily with demand. - Every member is tracked in one slot table (a
std::sync::Mutexnever held across an.await): an idle slot parks its session handle; a checked-out slot’s handle lives in theCheckout. Both states stay visible to the (sync) menu/status snapshots, which is how each individual auth is listed. - Session creation (browser SSO) is serialized across all pools by a
shared auth gate (held by the engine’s
createclosure) so only one auth window opens at a time.
Structs§
- Checkout
- A session checked out of a pool.
- Member
Info - A serializable snapshot of one pool member (one authenticated session).
- Pool
Registry - The account-agnostic registry of session pools, keyed by
(account, user). - Query
Context - A concrete statement context (resolved warehouse/role/database/schema names).
- Running
Query - The query a member is currently running (set while checked out).
- Session
Info - A serializable snapshot of one pool, used for
sessions/status/menu. - Session
Key - Identifies a pool by its
(account, user)— one authentication identity. - Session
Pool - A bounded pool of authenticated sessions for one
(account, user).