Skip to content

Conversation

@alexguo-db
Copy link
Contributor

@alexguo-db alexguo-db commented Jul 22, 2025

Proposed Changes

  • Currently, before we send an HttpRequest, we await RenewTokenIfNeededAsync which blocks the HttpRequest on the token refresh
  • Make this run in a non-blocking background task, so that a token refresh is triggered but the request will continue using the existing token
  • When the background task completes, use the new token
  • This is to improve latency since requests don't wait on the token refresh
  • The risk is that there is a potential to use expired tokens if the background task doesn't complete in time, however this can be mitigated by setting TokenRenewLimit property to refresh X minutes before the token expires

Testing

dotnet test --filter "FullyQualifiedName~TokenExchangeTests"

[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.1.1+bf6400fd51 (64-bit .NET 8.0.7)
[xUnit.net 00:00:00.04]   Discovering: Apache.Arrow.Adbc.Tests.Drivers.Databricks
[xUnit.net 00:00:00.12]   Discovered:  Apache.Arrow.Adbc.Tests.Drivers.Databricks
[xUnit.net 00:00:00.13]   Starting:    Apache.Arrow.Adbc.Tests.Drivers.Databricks
[xUnit.net 00:00:11.02]     Apache.Arrow.Adbc.Tests.Drivers.Databricks.Auth.TokenExchangeTests.TokenExchangeHandler_WithValidTokenNotNearExpiry_UsesOriginalToken [SKIP]
[xUnit.net 00:00:11.02]       Access token is too close to expiration for this test
[xUnit.net 00:00:11.34]   Finished:    Apache.Arrow.Adbc.Tests.Drivers.Databricks
  Apache.Arrow.Adbc.Tests.Drivers.Databricks test net8.0 succeeded (11.8s)

Test summary: total: 3, failed: 0, succeeded: 2, skipped: 1, duration: 11.7s
Build succeeded in 13.6s

dotnet test --filter "FullyQualifiedName~TokenExchangeDelegatingHandlerTests"

[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v3.1.1+bf6400fd51 (64-bit .NET 8.0.7)
[xUnit.net 00:00:00.06]   Discovering: Apache.Arrow.Adbc.Tests.Drivers.Databricks
[xUnit.net 00:00:00.14]   Discovered:  Apache.Arrow.Adbc.Tests.Drivers.Databricks
[xUnit.net 00:00:00.16]   Starting:    Apache.Arrow.Adbc.Tests.Drivers.Databricks
[xUnit.net 00:00:01.76]   Finished:    Apache.Arrow.Adbc.Tests.Drivers.Databricks
  Apache.Arrow.Adbc.Tests.Drivers.Databricks test net8.0 succeeded (2.4s)

Test summary: total: 14, failed: 0, succeeded: 14, skipped: 0, duration: 2.4s
Build succeeded in 3.8s

@github-actions github-actions bot added this to the ADBC Libraries 20 milestone Jul 22, 2025
@alexguo-db alexguo-db force-pushed the alex-guo_data/make-token-refresh-non-blocking branch from ba399bc to b71b36a Compare July 22, 2025 21:42
@CurtHagenlocher CurtHagenlocher merged commit a66d1e1 into apache:main Jul 22, 2025
7 checks passed
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