Skip to content

Concurrent calls to GetSession wait instead of falling back to bearer authentication - #7528

Open
wonwuakpa-msft wants to merge 3 commits into
mainfrom
wendi/wait-getsession
Open

wonwuakpa-msft wants to merge 3 commits into
mainfrom
wendi/wait-getsession

Conversation

@wonwuakpa-msft

Copy link
Copy Markdown
Member

Pull Request Checklist

Please leverage this checklist as a reminder to address commonly occurring feedback when submitting a pull request to make sure your PR can be reviewed quickly:

See the detailed list in the contributing guide.

  • C++ Guidelines
  • Doxygen docs
  • Unit tests
  • No unwanted commits/changes
  • Descriptive title/description
    • PR is single purpose
    • Related issue listed
  • Comments in source
  • No typos
  • Update changelog
  • Not work-in-progress
  • External references or docs updated
  • Self review of PR done
  • Any breaking changes?

Copilot AI balanced review requested due to automatic review settings November 5, 2026 17:34
@github-actions github-actions Bot added the Storage Storage Service (Queues, Blobs, Files) label Nov 5, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
9 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@wonwuakpa-msft wonwuakpa-msft changed the title Fixed race condition from concurrent calls to GetSession falling back to bearer auth Concurrent calls to GetSession wait instead of falling back to bearer authentication Nov 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The blobs test target cannot compile because of a duplicate test definition and an invalid SessionProvider constructor call, and four new concurrency tests leave sessions disabled in Auto mode.

3 open issues
What changed in this PR

This PR addresses concurrent Blob session requests falling back to bearer authentication while another caller is creating a session.

Changes:

  • Adds per-container locking to serialize session creation and refresh.
  • Uses bounded waits with cancellation checks and cached-session rechecks.
  • Adds concurrency regression tests and makes the test credential counter atomic.
File Description
sdk/​storage/​azure-storage-blobs/​test/​ut/​session_authentication_test.cpp Adds tests for concurrent creation, container independence, cancellation, and failure handling.
sdk/​storage/​azure-storage-blobs/​src/​private/​token_credential_session_provider.hpp Adds a timed session-creation mutex to each container cache entry.
sdk/​storage/​azure-storage-blobs/​src/​private/​token_credential_session_provider.cpp Coordinates concurrent session creation with cancellable waits and cache rechecks.

Review effort: Balanced

@Jinming-Hu

Copy link
Copy Markdown
Member

The production code change looks reasonable to me. However, the added tests are failing CI. Could we remove the test-code changes from this PR? The recently added session-feature tests already provide some indirect regression coverage for the updated code.

Please also update the  SessionMode::Enabled  documentation in  blob_options.hpp to explain that requests without a usable cached session wait for an in-flight session acquisition rather than immediately falling back to bearer authentication.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Storage Storage Service (Queues, Blobs, Files)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants