-
Notifications
You must be signed in to change notification settings - Fork 524
Diagnostics: Fixes race condition that can cause InvalidOperationException in CosmosOperationCancelledException.ToString() #5422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good!
NaluTripician
previously approved these changes
Sep 24, 2025
aavasthy
previously approved these changes
Sep 24, 2025
jeet1995
reviewed
Sep 24, 2025
Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs
Show resolved
Hide resolved
35e2c5d
kundadebdatta
previously approved these changes
Sep 25, 2025
Pilchie
reviewed
Sep 25, 2025
Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs
Show resolved
Hide resolved
Pilchie
previously approved these changes
Sep 25, 2025
Member
Pilchie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit on using namad parameters for the boolean so it's easier to see at the call-site what the bool is for.
Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Tracing/TraceWriter.TraceJsonWriter.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Resource/CosmosExceptions/CosmosOperationCanceledException.cs
Outdated
Show resolved
Hide resolved
3dd2061
Pilchie
approved these changes
Sep 25, 2025
This was referenced Oct 18, 2025
1 task
kirankumarkolli
pushed a commit
that referenced
this pull request
Oct 27, 2025
# Pull Request Template ## Description This PR fixes a regression in tracing introduced by #5422, which can lead to thread contention. The bug is that the locking expects Trace-names to be unique for different logical operations - but many of the strings passed into new root traces (logical operations) are not new string instances (with possibly same value) but constants - so same singelton string instances. In tehse cases the new code will provide unnecessary lock contention. The locking scope should be just the scope of the ITrace instance - so, this PR introduces a new instance-level lock object (something I tried to avoid initially to avoid allocation of a new object-instance per trace). The alternative (Id - is a ValueType) and (children is a List that is exposed via properties - locking it would not be guaranteed to be dead-lock free - woudl be unliekly but not impossble if caller locks on the returned value from the Childred property). ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) - [] New feature (non-breaking change which adds functionality) - [] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [] This change requires a documentation update ## Closing issues To automatically close an issue: closes #IssueNumber
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.
Pull Request Template
Description
Fixes race condition that can cause InvalidOperationException in CosmosOperationCancelledException.ToString() - especially when cross-regional hedging is enabled and E2E timeouts happen (CancellationToken being cancelled).
Type of change
Please delete options that are not relevant.
Closing issues
ICM#66334029