Repository navigation
fix(eventhubs): safely clean up uAMQP producer sessions after discovery failure - #7511
Open
Johnathan W (j7nw4r) wants to merge 9 commits into
Open
Johnathan W (j7nw4r) wants to merge 9 commits into
Johnathan W (j7nw4r) wants to merge 9 commits into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 7 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
/azp run cpp - event hubs |
|
No pipelines are associated with this pull request. |
Member
Author
|
/azp run cpp - eventhubs |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Management-client cleanup can race with concurrent properties queries during gateway recovery, causing a null dereference or use-after-free.
1 open issue
What changed in this PR
This PR improves Event Hubs producer cleanup after partition discovery fails, with supporting changes to shared uAMQP session lifetime handling. Public API signatures remain unchanged.
Changes:
- Track session initialization separately from management-client creation and unify explicit close with destructor cleanup.
- Defer native cleanup after failed session shutdown until the last owner releases it.
- Add cleanup regression tests and update the Event Hubs recording asset reference.
| File | Description |
|---|---|
sdk/eventhubs/azure-messaging-eventhubs/test/ut/properties_cleanup_test.cpp |
Tests discovery failures, partial initialization, and repeated close. |
sdk/eventhubs/azure-messaging-eventhubs/test/ut/CMakeLists.txt |
Registers cleanup tests and their uAMQP dependencies. |
sdk/eventhubs/azure-messaging-eventhubs/src/private/eventhubs_utilities.hpp |
Tracks session ownership and consolidates properties-client cleanup. |
sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md |
Documents the producer cleanup fix. |
sdk/eventhubs/assets.json |
Updates the recording asset reference. |
sdk/core/azure-core-amqp/test/ut/session_cleanup_tests.cpp |
Tests failed shutdown, shared ownership, retries, and missing shutdown. |
sdk/core/azure-core-amqp/test/ut/CMakeLists.txt |
Registers session cleanup tests and dependencies. |
sdk/core/azure-core-amqp/test/ut/cleanup_test_listener.hpp |
Provides a minimal TCP listener for cleanup tests. |
sdk/core/azure-core-amqp/src/impl/uamqp/amqp/session.cpp |
Defers cleanup after failed shutdown and shares shutdown logic. |
sdk/core/azure-core-amqp/src/impl/uamqp/amqp/private/session_impl.hpp |
Adds shutdown-failure state and a test injection point. |
sdk/core/azure-core-amqp/inc/azure/core/amqp/internal/session.hpp |
Documents ownership behavior after failed shutdown. |
sdk/core/azure-core-amqp/CHANGELOG.md |
Documents the uAMQP session cleanup fix. |
Review effort: Balanced
Johnathan W (j7nw4r)
marked this pull request as ready for review
October 26, 2026 23:19
Johnathan W (j7nw4r)
requested review from
Larry Osterman (LarryOsterman),
Rick Winter (RickWinter),
Josue Gomez (SwayGom),
Anton Kolesnyk (antkmsft),
Ashish Chhabria (axisc),
Eric Lam (MSFT) (hmlam),
Amit Bhatia (meetamitbhatia),
Sagar Patel (sagar0207),
SJ (sjkwak) and
Jeff Fisher (xirzec)
as code owners
October 26, 2026 23:19
Johnathan W (j7nw4r)
enabled auto-merge (squash)
October 27, 2026 14:20
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The default Rust backend ignores management-call cancellation, allowing a withheld response to keep the mutex locked and block ConsumerClient::Close() even after the close context expires.
1 open issue
1 resolved since last review
Review effort: Balanced
Bridge the operation context into the synchronous Rust wait so cancellation releases the properties mutex before close. Reject null results and replace failed management links before another query. Bound consuming management teardown and add real loopback regressions for both getters and public consumer close.
Revert c86152e and keep the properties-query lock and child-context cancellation specific to uAMQP. Rust keeps its initialization-only lock until management cancellation is implemented. Track the Rust implementation, recovery behavior, and regression tests in Azure/azure-sdk-for-rust#5527. Preserve the uAMQP discovery/session cleanup fix and checkpoint recordings.
Josue Gomez (SwayGom)
approved these changes
Oct 28, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Fix Event Hubs producer cleanup after partition discovery fails with uAMQP, so releasing the producer does not abort the process.
Track session initialization independently of management-client creation. Explicit close and destruction share the cleanup path, repeated initialization failures do not acquire duplicate polling references, and both session
Endoverloads preserve shutdown errors while permitting retry. Successful shutdown and the assertion for omitted shutdown remain supported.Properties-query synchronization, child-context cancellation, and stale-reference rejection apply to uAMQP. Rust retains its initialization-only lock; Rust cancellation, recovery, and concurrent cleanup are deferred to azure-sdk-for-rust#5527. Public API signatures are unchanged.
Refresh the two Blob Checkpoint Store recordings for current Storage SDK request headers and Arrow listing responses.
Evidence
Session was not ended before destruction.Concurrent uAMQP query/cleanup could release resources still in use.-Wno-error=unused-resultfor an existing warning in unchangedmessage_sender_receiver.cpp:929.Merge Danger
Door: Two-way. The change can be reverted without a data migration or public API change.
Blast Radius: AMQP. Changes affect discovery cleanup, uAMQP session ownership, and uAMQP properties-query synchronization. Rust management cancellation and bounded session teardown remain deferred.