Skip to content

feat(server-core): driverVersion option to swap cached drivers when credentials change - #12261

Open
bsod90 wants to merge 1 commit into
masterfrom
maxim/driver-version
Open

bsod90 wants to merge 1 commit into
masterfrom
maxim/driver-version

Conversation

@bsod90

@bsod90 bsod90 commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Update 2026-10-19 (design review with Pavel). driverVersion stays as a general fix for credentials a driverFactory reads per request, though the swap logic may be simplified. Identity passthrough no longer depends on it: #12323 adds access token updates to drivers (BaseDriver.updateAccessToken()).

POC — do not merge. Came out of the OIDC identity passthrough proof of concept. The Cloud side of that POC no longer depends on it (its BigQuery auth client refreshes tokens itself), so this PR stands on its own: it fixes rotating credentials for any driverFactory. An earlier revision was exercised on a staging Cube Cloud deployment with BigQuery (results below).

The problem in plain words

server-core builds one driver per orchestrator and data source, from the context of the first request that reaches it, and never rebuilds it. When a driverFactory derives credentials from the security context (a per-user OAuth or OIDC token), the driver keeps the first token forever. Once that token expires, every reconnect fails until the process restarts. This is the bug class behind several customer escalations (Snowflake and Databricks per-user OAuth).

sequenceDiagram
  participant U as User request
  participant S as server-core
  participant D as Cached driver
  participant W as Warehouse
  U->>S: query (token T1)
  S->>D: build driver with T1 (once)
  D->>W: connect with T1
  Note over D: T1 expires
  U->>S: query (token T2)
  S->>D: reuse driver (still T1)
  D->>W: reconnect with T1
  W-->>U: token expired
Loading

The fix: an explicit driverVersion

A new option, driverVersion(context) => string. It runs on every orchestrator lookup: once per API request, more often during a scheduled refresh run, and for the readiness probe with an empty context. When the string changes for an orchestrator, server-core:

  1. builds new drivers with driverFactory and the current context in the background, and runs testConnection() on them. The request does not wait: it and every request until the swap are served by the current drivers;
  2. swaps them into the cache in one synchronous step, so later lookups get them;
  3. releases the old drivers once anything that started on them has timed out: the longer of the query queue's and the pre-aggregation queue's executionTimeout, which default to CUBEJS_DB_QUERY_TIMEOUT (10 min). No separate delay to configure.

If the new drivers fail, the error is logged, the old ones stay and the same version is not retried for 10 s. A version asked for during a swap is not queued: a later request swaps to it. The first request after the readiness probe, when no driver is cached yet, just adopts its own context. Drivers built for no version, such as the readiness probe's (possibly a fallback credential), never serve a versioned request: it waits until a switch installs drivers for a version, its own or another request's, and fails if its own cannot be built. The contract for callers: change the version while the previous credential is still valid. The trigger is explicit: no config fingerprinting, no expiry parsing. The application decides what "a new credential" means.

flowchart LR
  R[request] --> V{driverVersion<br/>changed?}
  V -- no --> C[cached driver]
  V -- yes --> C
  V -- "yes, in background" --> B[build + testConnection<br/>new drivers]
  B -- ok --> SW[swap into cache]
  SW --> REL[release old drivers<br/>after the query timeout]
  B -- fails --> KEEP[keep old drivers<br/>back off 10 s]
Loading

What this PR changes

File Change
server-core/src/core/OrchestratorDrivers.ts (new) One orchestrator's driver cache and the version it was built for: getDriver (the driver factory), ensureVersion (the per-request check: starts a background swap unless one is running, backoff), and swap: rebuild every cached driver from the new context, install them in one synchronous step, schedule the old ones' release
server-core/src/core/SwappedDriverReleases.ts (new) Releases a replaced driver after the query timeout; shutdown and reset release the pending ones at once
server-core/src/core/server.ts Wiring only: checkDriverVersion in getOrchestratorApi, resolveDriverVersion, buildDriver, and re-lookup of an evicted orchestrator
server-core/src/core/OrchestratorApi.ts isReleased() so a swap finishing after eviction installs nothing
server-core/src/core/OrchestratorStorage.ts peek() for the same check
server-core/src/core/types.ts, optionsValidate.ts driverVersion option
docs driver_version config section; its Python and JavaScript examples handle the readiness probe's empty context: a fixed orchestrator id and a service credential from driver_factory.

Also fixed on the way: without separate pre-aggregation credentials, a pre-aggregation lookup that came first could orphan a driver when the regular lookup overwrote the shared alias. Both lookup orders now share one cache entry.

Related work

PR Relation
#11453 Same goal, triggered by config fingerprints. This PR replaces that trigger with an explicit version and reuses its alias and replace ideas.
#11661, #11834 LRU release and single-flight build; unchanged and relied on.
#11465 Releases every driver an orchestrator created; complementary.

Risks

Risk What a user would see Mitigation
Version flips between values on one orchestrator Constant driver rebuilds, and requests served by drivers built for another context's credentials The docs require contextToOrchestratorId to separate whatever the version depends on; every swap is logged as Driver Swap
A stream is still running when the old driver is released That stream is cut Streams have no timeout; documented in driver_version. Queries and pre-aggregation builds time out first
driverVersion throws The request fails (if it carries a security context) Contexts without one, like the readiness probe, just skip the swap

Off by default: nothing changes unless driverVersion is set.

Tests

packages/cubejs-server-core/test/unit/driver-version.test.ts, 33 cases (28 tests plus two parameterized tests with 3 and 2 cases): a queueOptions function that throws failing the swap before any driver is installed, requests served by the old drivers while the swap warms, drivers built for the readiness probe never serving a versioned request (it is served once another version's switch installs), a request waiting for a first version that starts no swap once its orchestrator is released, a throwing logger, swap with the new context, test-before-visible, concurrent single-flight, failure and backoff, a version asked for during a swap and swapped to by a later request, the first request after the readiness probe, release at the queue timeout (default, CUBEJS_DB_QUERY_TIMEOUT, and the longer of two queue timeouts) and releaseConnections(), chained swaps, both alias orders, constructed-driver factories, lazy data sources after a swap, reinstall of an older driver, swap finishing after eviction or release, and driverVersion errors. orchestrator-drivers.test.ts (2 cases) covers the bound on remembered failed swaps directly. Each test was checked to fail with its code reverted. The full server-core unit suite passes (262/262).

Verified on a staging deployment

An earlier revision of this PR (release after a fixed delay; the swap path is unchanged) ran under a real credential rotation: a Cube Cloud staging deployment on BigQuery (Workload Identity Federation), where every user's or group's token lives 10 minutes and the Cloud layer returns the token's issue time as the version.

Run Duration Queries Errors Swaps
1 12 min 32 0 (not logged at the default level)
2 (trace logging) 14 min 38 0 7 across 2 replicas, about every 5 min
  • Every swap kept the orchestrator id, so its queues and result cache survived each rotation.
  • Group members shared one orchestrator: the second member's query was served from the first member's result cache, and the warehouse ran one job per group.
  • No driver code changed. The factory runs again with the current context on each swap.

🤖 Generated with Claude Code

@mintlify

mintlify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
cubed3 🟢 Ready View Preview Nov 10, 2026, 6:32 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions github-actions Bot added docs Issues that require a documentation improvement javascript Pull requests that update Javascript code labels Oct 14, 2026
@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.58011% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.25%. Comparing base (56723bc) to head (8023829).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...cubejs-server-core/src/core/OrchestratorDrivers.ts 95.41% 2 Missing and 3 partials ⚠️
packages/cubejs-server-core/src/core/server.ts 95.91% 1 Missing and 1 partial ⚠️
...bejs-server-core/src/core/SwappedDriverReleases.ts 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12261      +/-   ##
==========================================
+ Coverage   83.23%   83.25%   +0.01%     
==========================================
  Files         530      532       +2     
  Lines      124922   125069     +147     
  Branches     5312     5341      +29     
==========================================
+ Hits       103981   104122     +141     
- Misses      20147    20151       +4     
- Partials      794      796       +2     
Flag Coverage Δ
cube-backend 66.53% <95.58%> (+0.25%) ⬆️
cubesql 86.85% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bsod90
bsod90 marked this pull request as ready for review October 14, 2026 23:09
@claude

claude Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 3m 4s —— View job


No blocking bugs; 0 high, 3 medium, 2 low. The swap and install logic holds up. The findings are an observability gap, stale docs, and a design limit.

Review details

Findings (posted inline)

Severity Location Issue
Medium packages/cubejs-server-core/src/core/server.ts:1057 The 5 s ping-pong window is measured from one install to the next. Swaps run one at a time and include testConnection(), so when a swap takes more than 5 s (common for Snowflake or Databricks), a real flip-flop never logs the warning. This is the warning the Risks table relies on.
Medium docs-mintlify/reference/configuration/config.mdx:583-586 The Warning still says "replaced more than once in 5 seconds". Since 1a7d9c6 the code warns only on a swap back to the version it just replaced.
Medium packages/cubejs-server-core/src/core/server.ts:982 A swap rebuilds and tests every data source of the orchestrator, all or nothing. An unrelated data source failing testConnection() blocks the token-backed driver's rotation and fails the request that triggered the swap. Other pools are rebuilt on every rotation.
Low packages/cubejs-server-core/src/core/server.ts:109 CUBEJS_DRIVER_SWAP_RELEASE_DELAY is read from process.env instead of being declared in cubejs-backend-shared/src/env.ts and read with getEnv.
Low docs-mintlify/reference/configuration/config.mdx:607 The Python example is for an option that is JavaScript-only, and it omits context_to_orchestrator_id.

Checked and found sound

  • Install step: the install after the isLive() check runs synchronously, so no lookup sees a partial swap. ctxRef.current changes in the same step, so lazy builds after the swap use the new context.
  • Lazy builds during a swap: the unswapped() loop rebuilds them. A build that fails drops itself without clobbering a replacement, because of the driverPromise[key] === pending guard.
  • Eviction or release mid-swap: discardBuilt() runs and getOrchestratorApi re-resolves, with no recursion loop.
  • Factories that cache driver instances: keep / cancelSwappedDriverRelease stop a reinstalled driver from being released under live queries.
  • Shutdown: releaseConnections / resetInstanceState / shutdown all flush swappedDriverReleases.
  • Pre-aggregation alias: the order fix (both keys share one promise) is correct.

Notes (not posted)

  • With the 600 s default delay, pre-aggregation builds or exports longer than 10 minutes on a swapped driver get cut off. The PR already lists this as a risk; consider saying so next to driverSwapReleaseDelay in the docs.
  • A request whose version is older than the current one swaps backwards, because any change counts, not just forward ones. That is fine given the "application defines the version" contract.
  • I did not run the tests in this job.

Review threads

The listing returned 0 of my own threads: none resolved, none re-affirmed (no prior threads).

Progress

  • Gather context (diff, changed files)
  • Review server-core swap logic
  • Review tests and docs
  • Resolve/dedupe prior review threads
  • Post findings

@bsod90
bsod90 requested review from a team and keydunov as code owners October 14, 2026 23:09
@claude

claude Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 3m 7s —— View job


Review of PR #12261: no correctness bugs found. Findings: 0 high, 1 medium (docs), 3 low.

Details
  • Gather context (diff, changed files)
  • Review server-core changes
  • Review tests and docs
  • Reconcile prior review threads
  • Post findings

Findings

Severity Where Issue
Medium docs-mintlify/reference/configuration/config.mdx:576 driverVersion runs on every getOrchestratorApi call. That includes the 9 calls in RefreshScheduler, one of them inside a per-partition loop. Refresh contexts carry a securityContext, so if driverVersion throws, the scheduled refresh fails. The docs and the PR body ("once per request") understate how often it runs and leave out refresh-worker contexts.
Low docs-mintlify/reference/configuration/config.mdx:611 The example's !securityContext guard is dead code. contextToOrchestratorId runs first on the probe's {} context and throws a TypeError on securityContext.tenant_id.
Low packages/cubejs-server-core/src/core/server.ts:741 (also :97, :189) These comments only repeat the name they sit on.
Low packages/cubejs-server-core/test/unit/driver-version.test.ts No test covers a request that waits on an in-flight swap to version V2, then starts its own swap to V3 (the second iteration of the loop at server.ts:699).

Checked and OK

  • Swap install is atomic: there is no await between the last unswapped() check, the isLive() check and the install. A data source built lazily during the swap cannot be missed.
  • The swap loop always ends: a success sets state.version; a failure sets lastFailure, which turns waiters on that version into backoff; an eviction makes isLive() false. Only the request that started a failed swap sees the error.
  • Factories that cache their driver instances: a reinstalled driver has its pending release cancelled, and keep() stops the failure paths from releasing drivers that are still in use.
  • Pre-aggregation alias fix: without separate pre-agg env vars, both keys now share one promise whichever lookup comes first, and the cleanup in .catch only clears keys still pointing at its own promise.
  • Shutdown: releaseConnections, resetInstanceState and shutdown all release drivers still waiting for their delayed release. The setTimeout value is capped at 2³¹−1 ms, so a long delay cannot overflow and fire at once.

Design note (not posted inline)

A swap rebuilds every data source on the orchestrator together. One data source that is down blocks rotation for all the healthy ones: every 10 s one request fails, and the rest keep the old, possibly expired, credentials. This is documented, but per-data-source swaps would contain the damage if multi-source orchestrators matter.

Not run

node_modules is not installed in this checkout, so I did not run the unit tests or lint. I also could not fetch origin/master (fetching needs approval), so I diffed against the PR's base commit 5538c92.

Review threads

The listing returned 0 threads of mine: none resolved, none re-affirmed. I posted 3 new inline comments.

@claude

claude Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 2m 25s —— View job


Looks good, no blocking issues: 0 high, 0 medium, 2 low (both posted inline).

Review details
  • Read diff and changed files
  • Analyze swap / release / backoff logic
  • Review tests and docs
  • Resolve stale threads / dedupe findings
  • Post review

Findings

Severity Where Issue
low packages/cubejs-server-core/src/core/server.ts:907 buildDriver's catch calls driver.release() without a guard. If release throws, its error replaces the credential failure, both in the swap request's error and in the Driver Swap Error log. Fix: use releaseDriverSafely.
low packages/cubejs-server-core/src/core/server.ts:810 The JSDoc on cancelSwappedDriverRelease is ungrammatical.

Checked and found sound

  • All-or-nothing install: nothing is awaited between the final unswapped() check, isLive() and the install loop. A lazy build cannot slip in with the old context and survive, because the loop rebuilds it and ctxRef.current changes in the same synchronous step.
  • Eviction or shutdown during a swap: isLive() sees peek() return undefined after clear() or eviction, so the drivers it built are discarded. releaseConnections and shutdown both drain swappedDriverReleases.
  • Failure handling: only the request that started a failing swap gets the error. Requests waiting on state.swapping go through the backoff and keep the old drivers. No path loops forever: a false result makes isLive() false on the next iteration, and the guard in checkDriverVersion stops getOrchestratorApi from recursing on a released api.
  • Shared pre-aggregation key: when there are no separate pre-aggregation env vars, both keys now share one promise. usePreAgg is false on both lookup orders, so the driver config is unchanged.
  • Release delay settings: env-var's asIntPositive accepts 0, which matches the documented "non-negative whole number" and the Joi min(0).
  • Tests: they use subclasses and fake timers, with no as any casts on protected members. I didn't run them: the workspace has no build (cubejs-backend-shared/dist is missing).

Not in scope, noted for context

  • OrchestratorApi.release() releases only the non-pre-aggregation key of each seen data source. A separate ds@pre_agg driver still leaks on eviction. This is not new in this PR; fix(server-core): release and connection-test dedicated pre-aggregation drivers #11465 covers it.
  • With driverVersion set, the request that triggers a swap pays the full build and testConnection() latency, and so do concurrent requests with the same new version. This is by design, but worth watching on warehouses with slow connects.

Review threads

The listing returned 0 prior threads of mine, so none were resolved or re-affirmed.

@claude

claude Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 2m 36s —— View job


No blocking issues at c85d411: 0 high, 0 medium, 1 low (dead state fields).

Review details
  • Read the diff and changed files (latest commit c85d411)
  • Review the swap logic in server.ts
  • Review tests and docs
  • Reconcile prior review threads
  • Post findings

Findings

Low: dead fields on DriverVersionState (packages/cubejs-server-core/src/core/server.ts:92-94, inline). Nothing reads state.ctxRef or state.swapping.version. Swaps and the driver factory both use the local ctxRef in the closure, and checkDriverVersion only reads swapping.promise. Drop both fields, or keep swapping as a bare promise.

Checked and fine

  • Commit c85d411: buildDriver now uses releaseDriverSafely, so a release that throws can't hide the testConnection() error. The new test covers this.
  • Install step: after the rebuild loop's last unswapped() there is no await before the drivers are installed. A lazy build therefore can't slip in between with the old context. ctxRef.current moves in the same synchronous step.
  • Waiters on a failed swap: .finally clears state.swapping before the awaited promise settles. Requests waiting on that swap then hit the backoff and get the old drivers instead of starting a duplicate swap.
  • Lifecycle: eviction, resetInstanceState and shutdown during an in-flight swap are all caught by isLive(), and the built drivers are discarded. Old drivers waiting on a release timer are released at once by releaseConnections, resetInstanceState and shutdown.
  • Drivers held by queries: QueryCache and PreAggregations call driverFactory(dataSource) for every query (for example PreAggregations.ts:529 and QueryCache.ts:689). No long-lived reference keeps a replaced driver past the swap, apart from work already running.
  • Caching factories: a factory that hands back a driver still waiting on its release timer gets that release cancelled, so it isn't released twice when the orchestrator is released.
  • Readiness probe first: if a context without a security context builds the orchestrator, the version starts as undefined. The first real request then swaps with zero keys, which moves ctxRef to a real context. That fixes the case where an orchestrator created by the probe built every lazy driver from an empty context.
  • Docs: they match the behaviour: every lookup calls driverVersion, errors with a security context are fatal, there is a 10 s backoff, the release delay can be configured, and Cube Store is excluded. The example scopes the orchestrator id and the version by the same tenant key.

Not run

node_modules isn't installed in this checkout, so I didn't run the unit suite or the linter. The review is based on reading the code.

Review threads

The listing returned 0 of my own unresolved threads: none to resolve and none to re-affirm. The one finding above was posted as a new inline comment.

@claude

claude Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 2m 14s —— View job


No issues found (0 high, 0 medium, 0 low). Nothing posted inline.

Review details
  • Read diff and changed files
  • Analyze correctness, comments, tests, docs
  • Reconcile prior review threads
  • Post findings

What I checked in fce3948

  • Swap atomicity and lazy builds. At packages/cubejs-server-core/src/core/server.ts, swapDrivers keeps looping over unswapped() until no key still points to a pre-swap promise. A data source first built during the swap is therefore rebuilt from the new context before install. The install step is synchronous, and ctxRef.current moves in that same step, so later lazy builds use the new context.
  • Failure handling. In the lazy-build path, .catch clears the keys before pending rejects, so previous[i] === null really does mean the entry was dropped. discardBuilt and keep stop a caching factory's shared instance from being released, whether the swap fails or succeeds. Since c85d411, releaseDriverSafely keeps the original testConnection error.
  • Eviction and shutdown. isLive() covers both OrchestratorApi.release() and LRU replacement. releaseConnections, resetInstanceState and shutdown all drain swappedDriverReleases. OrchestratorApi.release() releases only the current drivers through driverFactory, and the scheduled timers handle the replaced ones, so no driver is released twice.
  • Concurrency. Requests that still carry the old version are served right away while a swap is in flight. Requests with the new version wait on state.swapping. After a failure, those waiters fall back to the old drivers through the backoff, which matches the JSDoc ("only the request that starts a failing swap sees its error").
  • Env and validation. env-var's asIntPositive() accepts 0, which matches Joi.number().min(0) and the docs' "non-negative whole number".
  • Comments. Every new comment is 3 lines or fewer and gives a reason rather than restating the code.
  • Tests. I counted 22 cases: 20 test plus 2 test.each tables. They cover the swap paths, the alias orders, eviction and release. I didn't run them here because the sandbox blocks the jest invocation.

Notes (not defects)

  • An invalid CUBEJS_DRIVER_SWAP_RELEASE_DELAY is read in the constructor, so it breaks startup even when driverVersion is unset. Other env-backed options behave the same way, so I'm leaving it.
  • The PR body says "21 tests". The file has 20 test blocks plus 2 parameterised tables.

Review threads

The listing returned 0 of my own unresolved threads (no prior threads). I resolved none and re-affirmed none.

• branch `maxim/driver-version`

@claude

claude Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 2m 36s —— View job


Review of 4f458c6: 0 high, 1 medium, 1 low. A stream that outlives the query timeout still loses its driver, and the docs no longer say so.

Details

Findings

Medium: a stream that outlives the timeout loses its driver (packages/cubejs-server-core/src/core/server.ts:1036, inline comment)

  • A replaced driver now stays open for the longer of the two queues' executionTimeout.
  • QueryQueue puts that timeout on queries and pre-aggregation builds, but not on the 'stream' handler (QueryQueue.ts:960-975).
  • So a stream running longer than CUBEJS_DB_QUERY_TIMEOUT after a swap still has its driver released under it, and fails partway through.
  • The previous docs said work still running at release is cut off. The new text at docs-mintlify/reference/configuration/config.mdx:595 says the driver stays open until that work has timed out, which streams never do.
  • The JSDoc at server.ts:782 still names "a stream" as work that gets time to finish.
  • Fix: restore the caveat in both places, or keep the driver open while it has a live stream.
  • The call-site comment at server.ts:1036 repeats the queryTimeoutSeconds JSDoc and can go.

Low: PR description is out of date

  • It still describes driverSwapReleaseDelay, CUBEJS_DRIVER_SWAP_RELEASE_DELAY and a configurable 600 s delay, in the steps, the file table and the Risks table.
  • 4f458c6 removed all of them. The test count may also have changed.

Checked, no issue

  • queryTimeoutSeconds falls back to getEnv('dbQueryTimeout') exactly as QueryQueue.ts:126 does, including executionTimeout: 0. Reading the raw options avoids the driverFactory call that resolving queue concurrency can make (OptsHandler.ts:263).
  • A query or build gets its driver after it starts and is timed from that start. The release is scheduled at swap time, so it fires no earlier than the timeout of any query already running on the old driver.
  • Calling queueOptions synchronously is safe: user config validates it as an object (optionsValidate.ts:14). The QueueOptions | fn type is never a Promise.

Tests

I didn't run them: the checkout has no node_modules. The updated test.each covers the default, CUBEJS_DB_QUERY_TIMEOUT, and the longer of the two queue timeouts. No test covers a per-data-source queueOptions function.

Review threads

The listing returned 0 of my threads, so I resolved none and re-affirmed none. I opened 1 new inline thread.

Progress

  • Read diff and changed files
  • Analyze correctness, comments, tests, docs
  • Reconcile prior review threads
  • Post review

@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 58s —— View job


No issues in cd2920e (docs only): 0 high, 0 medium, 0 low.

Review details
  • Read the latest changes (cd2920e, docs only)
  • Review the code
  • Reconcile prior review threads
  • Post the review

What I checked

  • docs-mintlify/reference/configuration/config.mdx:676-678: the JavaScript driverVersion example now returns undefined when there is no securityContext. This matches the Python tab (config.mdx:655-658) and the rule that the readiness probe passes an empty context.
  • User-facing docs: the driver_version option is documented for both JavaScript and Python in config.mdx, so the docs requirement is met.
  • This push changes no code in server-core or backend-native. Earlier rounds already reviewed the swap logic.

Review threads

The listing returned 0 of my own unresolved threads, so there was nothing to resolve or re-affirm. No inline comments were posted this round.

@bsod90

bsod90 commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

@paveltiunov cd2920e305: rebased onto master, plus the JavaScript driverVersion docs example now guards a missing securityContext like the Python one. CI green, no open threads.

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 1m 59s —— View job


No new issues at 485a1bc (0 high, 0 medium, 0 low). The PR description is out of date, though (see below).

Review details
  • Gather context (diff, changed files)
  • Review OrchestratorDrivers, SwappedDriverReleases, server.ts
  • Review tests and docs
  • Review threads
  • Post findings

What I checked since the last round

The latest-wins queue is gone (2e94cd7), as are the ping-pong warning (b211799) and the inner rebuild loop (8bc34e2). I found no defects in the code that replaces them:

  • requestSwap no longer queues (OrchestratorDrivers.ts:246). Once the backoff has passed, it clears the version's stale error even while another swap is running. A waiter on probe-built drivers then asks again itself (OrchestratorDrivers.ts:223). I traced three cases:

    • The other version's swap fails: the waiter starts its own swap.
    • The waiter's own swap fails: it rethrows its own error.
    • The orchestrator is evicted or released: isLive() fails, no swap starts, and the waiter returns 'evicted'.

    There is no busy loop. The while only spins while swapping is set, and a swap that installs nothing always leaves either a failure entry or isLive() false.

  • A version still backing off keeps its stored error. awaitFirstVersion rethrows that error and does not start a swap, which matches a version still backing off during another swap keeps its own error.

  • Rebuild and install (OrchestratorDrivers.ts:295-313): there is no await between the last unswapped(run).size check, the isLive() check and install(). A driver built lazily cannot slip in between them. A probe build that fails during a swap leaves previous null, so install() skips it and forget() has already cleared its key.

  • Release timing: queryTimeoutSeconds reads the raw executionTimeout (a function or an object per data source), with CUBEJS_DB_QUERY_TIMEOUT as the fallback, the same default QueryQueue uses. Caching factories are handled: a reinstalled driver is cancelled, and keep protects drivers in use or awaiting release.

  • Wiring in server.ts:685-745: the creator skips the check because its build recorded the version. Waiters on buildingOrchestratorApis go through checkDriverVersion, and the evicted path looks the orchestrator up again.

  • Docs: config.mdx:596-691 matches the current behaviour. It says a version requested during a switch is not queued, and it has both a Python and a JavaScript example, each guarding a missing securityContext. driver_factory links to it. No new env var was added, so nothing is missing from environment-variables.mdx.

  • Tests: driver-version.test.ts now has 32 cases. They cover the no-queue path (:489, :630, :661, :692, :726). The private-member rule is respected: the tests read orchestratorDrivers through a subclass, not a cast.

PR description is stale

None of this changes the code; it only affects reviewers reading the description:

  • It still says "A version requested while a swap runs is swapped to once it ends (the latest one wins)". Since 2e94cd7 that version is not queued, and a later request that returns it starts the swap.
  • The Risks table still lists the ping-pong warning as the mitigation for a version flipping between values. That warning was removed in b211799. The docs now warn about mis-scoped contextToOrchestratorId instead.
  • "34 tests" is now 32.

Review threads

The listing returned 0 of my own threads, so none were resolved or re-affirmed.

@bsod90

bsod90 commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

@claude please review the new commits on 485a1bc603: the ping-pong warning, the latest-wins queue and the unreachable discarded install path are removed (Pavel's 'swap logic may be simplified'), a waiter on a released orchestrator starts no swap (tested), and the Python docs example loads on 3.9.

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 1m 16s —— View job


Review of cd2920e..485a1bc: no issues found (0 high, 0 medium, 0 low). The three removals simplify the swap without losing any behaviour the docs still promise. The released-orchestrator waiter fix is correct, and its test would fail without the fix.

Details
  • Read the diff cd2920e..485a1bc (7 commits)
  • Check the removed ping-pong warning, the removed queue and the removed discarded path
  • Check the released-orchestrator waiter fix and its test
  • Check the Python 3.9 docs example
  • Post review

Removals

  • Ping-pong warning: nothing refers to SWAP_PING_PONG_MS, previousVersion, lastSwapAt or Driver Swap Ping-Pong any more, in the source, the tests or the docs. The Warning in config.mdx now states the real cost of a shared orchestrator id: drivers built for another context's credentials. That is the more useful thing to say anyway.
  • Latest-wins queue: requestSwap (OrchestratorDrivers.ts:246) now starts a swap only when none is running. Every swap starts from there, so moving failures.delete out of startSwap loses nothing. With a version installed, a version asked for during a swap is served by the current drivers, and the next request that carries it starts the swap. This matches the non-blocking contract and the new docs sentence. The updated test checks that c and d are never built (['a', 'b', 'd']).
  • discarded install path: I confirmed it can't be reached. Only getDriver (:119, only when the key is empty), forget (:184, only on rejection) and install (:407) write to this.drivers. A promise whose previous resolved is never rejected later, so forget can't remove it. Only one swap runs at a time, so no other install can replace it either. keys is therefore never empty when next is set. Removing the separate rebuildAll loop also leaves the atomicity guarantee in place: the do/while still rechecks unswapped() in the same synchronous step as isLive() → install() → recordSwap(). LateLookupDrivers now hooks rebuildRound, so it still exercises that gap.

Waiter on drivers built for no version (:219-226)

I traced the cases now that there is no queue:

  • Another version's swap fails and this version is out of backoff: the first waiter to resume starts its own swap. Waiters that resume after it see swapping set and wait on that swap. There is no duplicate build.
  • This version is still backing off: requestSwap does nothing, swapping stays unset and failures still holds the error. The loop exits and the waiter rethrows its own error. The renamed test covers this.
  • Another version installs: the loop exits and the waiter is served by those drivers. This is the documented "first versioned install wins" behaviour, and the updated probe test checks it.
  • Released or evicted while waiting: the isLive() guard stops the re-request, the loop ends, and the waiter returns 'evicted', so checkDriverVersion looks the orchestrator up again. The new test discriminates: without the guard, requestSwap('b') runs on the released orchestrator and builds a b driver, and built.some(... 'b') fails. Making b fail as well keeps the bad path from looping, as the test's comment says.

Docs

  • The Python tab now uses Optional[str] with from typing import Optional, so it loads on 3.9.
  • The switch paragraph is rewrapped. Its one short line ("have timed out: the longer of the query and") is the line before the long link, so that's fine.

Notes (not defects)

  • install() now silently skips a built next whose keys have disappeared. As shown above, that can't happen today. If a later change adds another writer to this.drivers, that driver would leak. A one-line comment on the invariant next to :397 would protect it, but this is optional.
  • The PR body's count of 32 tests matches: 29 test/test.each blocks in driver-version.test.ts and 3 in orchestrator-drivers.test.ts.

Not done

  • I didn't run the tests or lint. This review comes from reading the code.
  • I didn't list or resolve earlier threads. No new inline comments were posted.
• [`maxim/driver-version`](https://github.com/cube-js/cube/tree/maxim/driver-version)

@bsod90

bsod90 commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

@claude please review 531a43ce10: the driver_version example's context_to_orchestrator_id / contextToOrchestratorId now return a fixed id when there is no security context (the readiness probe calls adapterApi({})). The description now uses the docs' wording for drivers built for no version, says the option runs on every orchestrator lookup, and gives the test count as 32 cases (27 tests plus two parameterized ones with 3 and 2 cases) plus 3 in orchestrator-drivers.

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 43s —— View job


Review of 531a43ce10: 0 high, 1 medium, 0 low. The new guard on context_to_orchestrator_id is correct, but the probe is still DOWN: the example's driver_factory throws on the same empty context.

Details
  • Read the 531a43c diff
  • Trace the readiness probe through the example config
  • Check the PR description claims (test count, wording)
  • Post review

Medium: the example still makes the readiness probe report DOWN (docs-mintlify/reference/configuration/config.mdx:663-667, :683-688)

The commit message says the guard keeps the probe from turning DOWN for anyone who copies the example. It doesn't fix that yet, because the probe also builds a driver:

  • The standalone readiness handler (packages/cubejs-api-gateway/src/gateway.ts:3468-3472) calls adapterApi({}), then addDataSeenSource('default'), then testConnection().
  • OrchestratorApi.testConnection() (packages/cubejs-server-core/src/core/OrchestratorApi.ts:191-193) calls driverFactory('default') for every seen data source. Because 'default' was just added, the user's driver_factory runs with the empty context.
  • Both example factories read the security context with no guard: ctx['securityContext']['tenant_id'] in Python (a KeyError) and securityContext.tenant_id in JavaScript (a TypeError). The probe catches the error and reports DOWN.

The orchestrator lookup now succeeds and returns CUBE_APP, but the failure has only moved one step later. The docs sentence "Drivers built for no version, such as the readiness probe's" also assumes the probe gets a driver, which this example never gives it.

This also corrects a note in my earlier round (2026-10-15). I said there that the probe builds no driver because seenDataSources is empty on a new orchestrator. That was wrong: the probe adds 'default' itself before testing.

Options:

  • Give driver_factory a fallback for the probe, for example a service credential when there is no security context. That is exactly the "drivers built for no version" case, and versioned requests never use those drivers. Or
  • Keep the factories as they are, and add one sentence saying that with per-user credentials only, the readiness probe reports DOWN unless driver_factory handles a context with no security context. Then the context_to_orchestrator_id guard can stay or go; on its own it doesn't keep the probe up.

Fix this →

Checked and fine

  • The guard itself: ctx.get('securityContext') / securityContext ? return CUBE_APP for the probe. That can't collide with a tenant id, because tenant ids always get the CUBE_APP_ prefix. The Python and JavaScript tabs now match for both context_to_orchestrator_id and driver_version.
  • Test count in the description: driver-version.test.ts has 27 test blocks and 2 test.each tables (3 + 2 rows), so 32 cases. orchestrator-drivers.test.ts has 3 tests. This matches the description.
  • Description wording: it now says the option runs on every orchestrator lookup (per request, many times per refresh run, and for the probe), and it describes drivers built for no version in the same words as the docs. Both match the code.

Not done

  • I didn't run tests or build the docs. This commit only changes the docs.
  • I didn't list or resolve earlier threads, and I posted no inline comments.
• [`maxim/driver-version`](https://github.com/cube-js/cube/tree/maxim/driver-version)

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 1m 41s —— View job


No issues in b211799..531a43c: 0 high, 0 medium, 0 low.

Review details
  • Read the new commits and the changed files
  • Review the swap simplification, the released-orchestrator waiter, and the docs
  • Resolve stale review threads
  • Post the review

What I checked

  • Ping-pong warning removed: nothing still refers to previousVersion, lastSwapAt or SWAP_PING_PONG_MS. The context_to_orchestrator_id warning in the docs now describes the real consequence (requests served by another context's drivers) instead of a log line that no longer exists.
  • Latest-wins queue removed (requestSwap, packages/cubejs-server-core/src/core/OrchestratorDrivers.ts:246): a version asked for during a swap is dropped. Requests already served by the current drivers ask again on their next lookup, which fits the "change the version while the old credential is valid" contract.
    • The waiter path is the one case where nothing would ask again: drivers were built for no version, and another version's swap fails. awaitFirstVersion (OrchestratorDrivers.ts:219-226) covers it by asking for its own swap once the other one ends.
    • With several waiters, the first to resume starts the swap and the rest see swapping and wait. Every swap either installs a version, which ends all waits, or records a failure for its own version, which ends that version's waiter. Waiting is therefore bounded.
    • A waiter whose own version is still backing off starts nothing. It then rethrows its stored error: while no version is installed, recordFailure writes backoffs and failures together, and requestSwap deletes the failures entry only once the backoff has passed.
    • The isLive() guard before the retry is covered by the new test at driver-version.test.ts:661. After releaseConnections(), both requests take the 'evicted' path into a fresh orchestrator that has no drivers, so they adopt their version without building anything. The built assertion checks the right thing.
  • discarded install path: I confirmed it is unreachable. Only install and forget remove entries from this.drivers, and forget only drops a promise that rejected. A previous that resolved therefore always still has a key at install time, because swaps are single-flight.
  • Rebuild loop folded into swap (OrchestratorDrivers.ts:295-297): it behaves the same as before. The unswapped check and install still run in the same synchronous step, and a lazy build that fails is recorded with next: null, so the loop cannot spin on it.
  • Docs: Optional[str] loads on Python 3.9. Both examples now handle the readiness probe's missing securityContext in context_to_orchestrator_id as well as in driver_version.

Not done

I could not run jest: running npx jest in packages/cubejs-server-core needs permission this run doesn't have. I did not run the new tests or the full suite; this review comes from reading the code only.

Review threads

The listing returned 0 of my own unresolved threads, so none were resolved or re-affirmed. The user-facing docs requirement is met: driver_version is documented in docs-mintlify/reference/configuration/config.mdx.

@bsod90

bsod90 commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Medium fixed in 91daf5acfa: the example's driver_factory (Python and JavaScript) now returns a service credential when there is no security context, so the readiness probe's testConnection() on default gets a driver instead of a KeyError/TypeError. That is the 'built for no version' driver the text describes; versioned requests never use it. Both examples were run with an empty context and a tenant context.

@claude please re-review.

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 43s —— View job


Review of 91daf5acfa: no issues found (0 high, 0 medium, 0 low). The medium from my last round is fixed: with the example config, the readiness probe now reports UP.

Details
  • Read the 91daf5a diff
  • Trace the readiness probe through the example config again
  • Compare the Python and JavaScript tabs
  • Post review

Following the probe through the example

The standalone readiness handler calls adapterApi({}), then addDataSeenSource('default'), then testConnection(). Each of those steps now works with the empty context:

  1. context_to_orchestrator_id / contextToOrchestratorId returns CUBE_APP (from 531a43c).
  2. driver_version / driverVersion returns None / undefined. The orchestrator is built with no version.
  3. driver_factory / driverFactory, called for default from OrchestratorApi.testConnection(), now takes the get_service_token() / getServiceToken() branch. Before this commit it threw a KeyError / TypeError. The probe gets a real driver and testConnection() runs against the service credential.

Why the service credential can't serve a tenant

The probe's driver lives in the CUBE_APP orchestrator. Tenant ids always get the CUBE_APP_ prefix, so no tenant request ever looks that orchestrator up. If a misconfigured id did collide, the core guard would still apply: a versioned request never runs on drivers built for no version. So the fallback credential stays contained either way.

Consistency

  • The two tabs now match in all three functions. Each guards the missing securityContext the same way, and each explains the fallback in a one-line comment.
  • The Python tab still loads on 3.9 (Optional[str], no X | Y annotations).
  • The driver_factory dicts are collapsed to one line, which is fine at this length.
  • The prose ("Drivers built for no version, such as the readiness probe's") now matches the example: the probe really does build such a driver.

Optional nit (not a defect)

In this example the probe's drivers sit in their own orchestrator, so the exception for "drivers built for no version" never triggers here. It only matters when the probe shares an id with real requests. The text is accurate as a general rule, so no change is needed.

Not done

  • I didn't run the examples, the tests or the docs build. This commit only changes docs, and this review comes from reading them.
  • I didn't list or resolve earlier threads, and I posted no inline comments.
• [`maxim/driver-version`](https://github.com/cube-js/cube/tree/maxim/driver-version)

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 38s —— View job


Clean: no issues at 91daf5a (0 high, 0 medium, 0 low)

Review details
  • Read the new commits and the changed files
  • Review
  • Review threads
  • Post results

What changed since the last round

531a43c and 91daf5a are docs-only and touch the driver_version example in docs-mintlify/reference/configuration/config.mdx:648-689.

  • context_to_orchestrator_id / contextToOrchestratorId now return CUBE_APP when there is no security context. Before this, the readiness probe's adapterApi({}) hit a KeyError (Python) or a TypeError (JavaScript).
  • driver_factory / driverFactory now use get_service_token() / getServiceToken() when there is no security context. This means testConnection() on default gets a driver for the probe.
  • The two examples behave the same way, and the Python one uses Optional[str], so it loads on 3.9.

The new comment in the code ("which no versioned request uses") matches what happens at runtime. In this example the probe resolves to its own orchestrator id (CUBE_APP), while tenant requests resolve to CUBE_APP_<tenant>. So the service-credential driver never shares a cache with a versioned request, and the awaitFirstVersion path at packages/cubejs-server-core/src/core/OrchestratorDrivers.ts:214 isn't reached in this setup. That is the intended result.

I also re-read OrchestratorDrivers.ts as of this head: ensureVersion, the requestSwap path that starts no queued swap, awaitFirstVersion re-requesting after another version's swap installs nothing, and install/settle. I found no new issues. These two commits don't touch any source or test files, so I didn't re-run the unit suites this round.

Review threads

The listing returned 0 of my own unresolved threads, so there was nothing to resolve or re-affirm.

@bsod90

bsod90 commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

@claude please review 9fabd2e129: the OIDC docs page now says a token config bound to a data source for passthrough is not exposed in the security context, so configuration code reading oidcTokens.<name> gets nothing for it.

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 32s —— View job


Review of 9fabd2e129 (docs only): 0 high, 0 medium, 2 low. The sentence is in the right place, right after the description of the oidcTokens.<name> shape. But the page never says what "bound to a data source for passthrough" means, so readers can't tell whether it applies to them.

Details
  • Read the 9fabd2e diff
  • Read the surrounding "Per-user tokens" section of docs-mintlify/admin/deployment/oidc/index.mdx
  • Search the page and the repo for related terms
  • Post review

Low: "bound to a data source for passthrough" is not defined anywhere (docs-mintlify/admin/deployment/oidc/index.mdx:240)

  • The page has no other mention of "passthrough", or of binding a token config to a data source. The fields table at :102 has no such field, and neither do the dialog screenshot or the per-user section.
  • A reader who set up a per-user config by following this section can't tell whether their config is "bound". If it is, the driverFactory example at :268 silently gets undefined.
  • Fix: name the setting where the binding is made, in the UI or the API, and link to the page that explains passthrough (or feat(drivers): Access token update on the Snowflake and BigQuery drivers #12323 once it is documented). Also say what to do instead: the driver gets the token itself, so driverFactory doesn't need to read it.

Low: "gets nothing" is vague

The two documented shapes are { status: "active", … } and { status: "error", … }. "Gets nothing" could mean either of two things:

  • the key is absent, so oidcTokens.<name> is undefined;
  • or the oidcTokens object is missing entirely.

Which one matters for code like sc?.cubeCloud?.oidcTokens?.["snowflake-user"] and for status checks. Suggested wording:

A per-user config bound to a data source for passthrough is left out of oidcTokens: its tokens go only to that data source's driver, so oidcTokens.<name> is undefined for it.

That also says "per-user", which this sentence implies but doesn't state. Deployment-level configs never appear in oidcTokens anyway.

Not verified

  • I couldn't check the behaviour itself. Minting tokens and binding them to a data source happens in Cube Cloud, not in this repo: oidcTokens appears only on this docs page. So this review covers wording and consistency only.
  • Scope note: this sentence is about identity passthrough, which the PR's 2026-10-19 update says no longer depends on driverVersion. It may sit better with feat(drivers): Access token update on the Snowflake and BigQuery drivers #12323 than in this PR, though leaving it here does no harm.

Review threads

I didn't list or resolve earlier threads, and I posted no inline comments.

• [`maxim/driver-version`](https://github.com/cube-js/cube/tree/maxim/driver-version)

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 1m 10s —— View job


Review of 9fabd2e: 0 high, 0 medium, 1 low. The driver_version examples now work for the readiness probe. One docs sentence on the OIDC page is out of scope for this PR.

Details
  • Read the diff since the last review (485a1bc..9fabd2e) and the changed files
  • Review the code, tests and docs
  • Review threads
  • Post the review

Scope

Since 485a1bc, only docs changed (531a43c, 91daf5a, 9fabd2e). I re-read packages/cubejs-server-core/src/core/OrchestratorDrivers.ts in full at the head.

Findings

Low: docs-mintlify/admin/deployment/oidc/index.mdx:240 (inline). The sentence refers to a token config "bound to a data source for passthrough", but no docs page describes that binding, and it is unrelated to driverVersion. It belongs with the identity passthrough work (#12323).

Verified

  • config.mdx, driver_version examples (Python and JavaScript): with no security context, context_to_orchestrator_id returns the fixed id CUBE_APP and driver_factory returns a service credential. The readiness probe therefore gets its own orchestrator and a working driver. Tenant orchestrators never hold drivers built for no version, which matches the text above the examples.

  • OrchestratorDrivers.ts at the head:

    • requestSwap clears a stale error before the single-flight check.
    • awaitFirstVersion asks again after another version's swap that installed nothing.
    • swap checks isLive() and leftover un-rebuilt drivers in the same synchronous step as install.

    I found no new issues.

  • User-facing docs: the driverVersion / driver_version option is documented in config.mdx, with Python and JavaScript tabs.

Review threads

The listing returned 0 of my own unresolved threads, so none were resolved or re-affirmed.

@bsod90

bsod90 commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Both docs lows addressed in 8f0bd74184: the oidcTokens note concerns identity passthrough, not driverVersion, so it moved to #12323, reworded to name the setting and to say oidcTokens.<name> is undefined. This PR no longer touches that page.

@claude please re-review.

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 30s —— View job


Review of 8f0bd74184: no issues found (0 high, 0 medium, 0 low). Both docs lows from the last round are resolved, because the sentence is now out of this PR.

Details
  • Read the 8f0bd74 diff
  • Confirm the PR no longer changes the OIDC page
  • Post review

What I checked

Not done

  • I didn't run tests or the docs build. This commit only removes docs lines.
  • I didn't list or resolve earlier threads, and I posted no inline comments. The OIDC inline thread from last round can be resolved now that the line is gone.
• [`maxim/driver-version`](https://github.com/cube-js/cube/tree/maxim/driver-version)

@claude

claude Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 52s —— View job


No issues found in 8f0bd74: 0 high, 0 medium, 0 low.

Review details
  • Read the diff since the last review round
  • Review the changed files
  • Review threads
  • Post the review

Scope

The only change since 531a43c is in docs-mintlify/reference/configuration/config.mdx (91daf5a). The OIDC note was added in 9fabd2e and then removed in 8f0bd74 (moved to #12323), so it nets to nothing here. The server-core code is unchanged since the last round.

driver_version example (config.mdx:648-689)

  • With no security context, driver_factory / driverFactory now use a service credential. The readiness probe's testConnection() on default therefore gets a driver instead of failing with a KeyError or TypeError.
  • The example still works with the empty context the readiness probe passes:
    • context_to_orchestrator_id returns the fixed id CUBE_APP.
    • driver_version returns None/undefined, so the drivers on that id are "built for no version", as the prose at config.mdx:605-607 describes.
    • Tenant requests resolve to CUBE_APP_<tenant>, so the service-credential driver never serves a versioned request.
  • The Python and JavaScript tabs match each other. The added comment is one line and explains why the fallback is there.

Docs requirement

The new option is documented in config.mdx, with Python and JavaScript examples. No other user-facing change in the diff is undocumented.

Review threads

The listing returned 1 of my own threads. I resolved it (docs-mintlify/admin/deployment/oidc/index.mdx): the passthrough sentence it was about was removed in 8f0bd74. No threads were re-affirmed.

@bsod90

bsod90 commented Oct 31, 2026

Copy link
Copy Markdown
Member Author

@paveltiunov ready for review at 8f0bd74184. Since your last look, the swap logic is simplified as you suggested: the ping-pong warning, the latest-wins queue and an unreachable install path are gone, and a request waiting on a released orchestrator starts no swap. The driver_version docs example now handles the readiness probe's empty context and loads on Python 3.9. The end-to-end passthrough run used this server-core (driverVersion itself is not on that path). CI: everything passes except Build macos-14 aarch64-apple-darwin 24.x with Python fallback, which GitHub cancels one second after it starts, on master too (runner issue, not this PR). No open threads.

@bsod90
bsod90 force-pushed the maxim/driver-version branch from 8f0bd74 to 7909641 Compare November 10, 2026 06:19
@claude

claude Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 1m 40s —— View job


Review of 7909641: no blockers. 0 high, 0 medium, 1 low

Details
  • Read the diff and changed files
  • Review code, tests, docs, comments
  • Resolve stale review threads
  • Post findings

Findings

  • Low: packages/cubejs-server-core/src/core/OrchestratorDrivers.ts:273 (inline). queryTimeoutSeconds() runs the user's queueOptions(dataSource) function after the cache entries already point at the new drivers. If that function throws, the swap ends up half-installed: version stays old, some replaced drivers are never scheduled for release and leak, and the version is swapped again once the backoff passes. Fix: work out the timeouts before the install.

Checked, no issues

  • Swap paths. Swapping in the background, waiting after the readiness probe (ensureVersion re-asks for its own version when another version's swap installed nothing), per-version backoff and its 16-entry cap, and the do…while rebuild loop. That loop can't spin, because a failed lazy build drops itself from the cache before stale() runs again.
  • Install and release. The install is synchronous with the last stale() check. Shared ds / ds@pre_agg entries are now one CachedDriver, whichever key is asked for first. A caching driverFactory that hands back the same instance is kept open through keep / releases.cancel.
  • Eviction. checkDriverVersion re-looks up an evicted orchestrator. The creator skips the check because the build records its version. releaseConnections, shutdown and resetInstanceState all call releaseAll().
  • Release timeout. It matches QueryQueue's default (options.executionTimeout || getEnv('dbQueryTimeout')).
  • Docs. driver_version is documented in docs-mintlify/reference/configuration/config.mdx with JavaScript and Python examples. Both handle the readiness probe's empty context. The driver_factory note and the CUBEJS_DB_QUERY_TIMEOUT anchor are correct. Python wiring is done (cube_config.rs, __init__.py, PyConfiguration, a native test).
  • Comments. All are within 3 lines and explain why the code is the way it is.

Not run

I didn't run the unit tests (driver-version.test.ts, orchestrator-drivers.test.ts): this job isn't allowed to run jest. The PR reports 251/251 server-core tests passing.

Review threads

The listing returned 0 of my own threads, so there was nothing to resolve or re-affirm. The finding above is a new thread.

…version changes

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LNEgK1REDundqTqsVrpApd
@claude

claude Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @bsod90's task in 2m 12s —— View job


No issues found at 8023829: 0 high, 0 medium, 0 low.

Review details
  • Gather context (diff, changed files)
  • Review OrchestratorDrivers / SwappedDriverReleases / server.ts
  • Review docs, Python config, tests
  • Review threads
  • Post findings

What I checked

  • Swap install (packages/cubejs-server-core/src/core/OrchestratorDrivers.ts:229-294): the rebuild loop re-checks stale() in the same synchronous step as the install, so a driver built lazily from the old context can't slip in between. queryTimeoutSeconds() runs before any cached.driver is reassigned, so a throwing queueOptions fails the whole swap and installs nothing. On failure or eviction, rebuilt drivers are released unless keep says they are in use.
  • Waiting on drivers built for no version (OrchestratorDrivers.ts:131-152): the wait loop ends in every branch. It ends when another version's swap fails (it re-requests its own), when its own version is backing off (failures.has), and when the orchestrator stops being live (swapping stays unset). A stale error is dropped in requestSwap before a retry starts, so a waiting request can't get an old error.
  • Release timing: the default executionTimeout || getEnv('dbQueryTimeout') matches QueryQueue (cubejs-query-orchestrator/src/orchestrator/QueryQueue.ts:135). releaseConnections, resetInstanceState and shutdown all drain the pending releases after releasing the orchestrators. released is set synchronously at the start of OrchestratorApi.release(), so a swap that finishes during shutdown installs nothing.
  • Wiring (server.ts:685-830): the creator records its version during the build. Waiters on buildingOrchestratorApis and cache hits go through checkDriverVersion. An eviction during the wait re-resolves through getOrchestratorApi.
  • Python: driver_version is registered in cube_config.rs and typed Optional[str]. pythonLoadConfig passes it through generically, and ?? undefined turns a Python None (null) into "no version".
  • Docs: the driver_version section in docs-mintlify/reference/configuration/config.mdx covers the new option, the readiness-probe case, backoff, release timing and the shared-orchestrator-id warning. The JS and Python examples both handle an empty context.
  • Comments: every comment is 3 lines or fewer, and none just restates the code below it.

Not run

I didn't run the unit tests (driver-version.test.ts, orchestrator-drivers.test.ts): this checkout has no node_modules, so jest isn't available. This review relies on reading the code and on the PR's CI.

Review threads

The listing returned 1 of my own unresolved threads, and I resolved it:

  • OrchestratorDrivers.ts, a swap left half-installed when queueOptions throws: fixed, because the release timeouts are now worked out before the install (OrchestratorDrivers.ts:250-261).

No threads re-affirmed, no new inline comments.

@bsod90

bsod90 commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

@paveltiunov ready for review at 8023829400: rebased, one commit. The swap is simpler, as you suggested: one swap() instead of nine step methods and one failure map, so the server-core source is +516 lines (was +678). driver-version.test.ts passes unchanged.

This branch was successfully deployed

1 active deployment
staging - docs-mintlify — 80238294 Deployed Nov 10, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Issues that require a documentation improvement javascript Pull requests that update Javascript code python rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant