Skip to content

Conversation

@samikshya-db
Copy link
Collaborator

@samikshya-db samikshya-db commented Oct 29, 2025

Description

  • The issue :
    • An E2E test conducted with JDBC, with additional SDK-level logging, confirmed that the SDK was refreshing tokens on every call—even when successive calls occurred within seconds. This behavior occurred despite Databricks M2M tokens being valid for 59 minutes. As a result, the token endpoint was hit excessively, eventually triggering global rate limits and throttling for the IP.
    • Each getToken call in the SDK fetched a new token from the server because the SDK did not cache tokens correctly. This was traced to a regression in the SDK’s token management logic.
  • This PR ensures that the SDK is configured once in the constructor, preventing repeated token endpoint calls. We also plan to perform a broader SDK code audit to identify and address any similar issues going forward.

Testing

  • Tested manually using M2M flow : The token retrieval is now performed only once when M2M creds are used.
  • Unit tests

Additional Notes to the Reviewer

@samikshya-db samikshya-db requested a review from gopalldb October 29, 2025 04:39
@samikshya-db samikshya-db marked this pull request as ready for review October 29, 2025 04:55
@samikshya-db samikshya-db changed the title Fix regression in tokenFederation Fix regression in sdk (changes in token federation) Oct 29, 2025
assertEquals("https://sample-host.18.azuredatabricks.net", config.getHost());
assertEquals("test-client", config.getClientId());
assertEquals("custom-oauth-m2m", provider.authType());
assertEquals(DatabricksJdbcConstants.M2M_AUTH_TYPE, config.getAuthType());
Copy link
Collaborator

Choose a reason for hiding this comment

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

no other tests needed?

// because URLs are generated inside SDK
if (DriverUtil.isRunningAgainstFake()) {
return this.credentialsProvider.configure(databricksConfig);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

is configure always called once?

@gopalldb gopalldb merged commit d107cb4 into databricks:main Oct 29, 2025
12 of 13 checks passed
gopalldb added a commit that referenced this pull request Oct 29, 2025
- The issue :
- An [E2E
test](https://docs.google.com/document/d/1McX4IgD-ZBTtiNXNUrEemsjbVj3oeoQYDwegjjln6UA/edit?ouid=113104269373381935368&tab=t.0#heading=h.k832j8h2svg)
conducted with JDBC, with additional SDK-level logging, confirmed that
the SDK was refreshing tokens on every call—even when successive calls
occurred within seconds. This behavior occurred despite Databricks M2M
tokens being valid for 59 minutes. As a result, the token endpoint was
hit excessively, eventually triggering global rate limits and throttling
for the IP.
- Each [getToken call in the
SDK](https://github.com/databricks/databricks-jdbc/blob/a17b84c1a0418094a8434f56246c764fa235d19b/src/main/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksHttpTTransport.java#L166)
fetched a new token from the server because the SDK did not cache tokens
correctly. This was traced to a regression in the SDK’s token management
logic.
- This PR ensures that the SDK is configured once in the constructor,
preventing repeated token endpoint calls. We also plan to perform a
broader SDK code audit to identify and address any similar issues going
forward.

- Tested manually using M2M flow : The token retrieval is now performed
only once when M2M creds are used.
- Unit tests

- Internal doc :
https://docs.google.com/document/d/1McX4IgD-ZBTtiNXNUrEemsjbVj3oeoQYDwegjjln6UA/edit?tab=t.g07tag19b223

---------

Co-authored-by: Gopal Lal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants