Skip to content

fix(session): authenticate once before resolving feature flags - #423

Merged
vuanhphung merged 1 commit into
mainfrom
vuanhphung/auth-once-before-feature-flags
Nov 4, 2026
Merged

vuanhphung merged 1 commit into
mainfrom
vuanhphung/auth-once-before-feature-flags

Conversation

@vuanhphung

Copy link
Copy Markdown
Collaborator

When a driver identity is set, the feature-flag prefetch in Session::open is the first caller of the auth provider. If the token request fails there, the error is swallowed (flags fail open) and nothing is cached, so CreateSession immediately sends the token request again, with no backoff and ignoring Retry-After. Every failed open costs two token requests, exactly when the token endpoint is already overloaded. In the RE-17407 M2M benchmark (19,200 sessions opened in a burst), this added 9,968 token requests (+52%) while /oidc/v1/token was returning 503s.

Session::open now authenticates once right after the auth provider is attached. The prefetch and CreateSession reuse the cached token, and a token failure fails the open with the original error. Successful opens are unchanged at one token request.

New tests: a failed open against a 503 + Retry-After: 60 token endpoint sends one token request (two before this change), and a successful M2M open uses one token for both the flag fetch and CreateSession.

This pull request and its description were written by Isaac.


This PR was created with GitHub MCP.

The feature-flag prefetch was the first caller of the auth provider and
swallows its errors, so a failed token request was sent again by
CreateSession with no backoff. Authenticate once right after the provider
is attached; the prefetch and CreateSession reuse the cached token.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

This branch was previously deployed

1 inactive deployment
azure-prod — 9954bf18 Deployed Nov 3, 2026 by vuanhphung via v0 TLS (mitmproxy) #1084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants