Skip to content

Conversation

@FabianMeiswinkel
Copy link
Member

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.

  • 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

ICM#66334029

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

All good!

NaluTripician
NaluTripician previously approved these changes Sep 24, 2025
aavasthy
aavasthy previously approved these changes Sep 24, 2025
@FabianMeiswinkel FabianMeiswinkel changed the title Fixes race condition that can cause InvalidOperationException in CosmosOperationCancelledException.ToString() Diagnostics: Fixes race condition that can cause InvalidOperationException in CosmosOperationCancelledException.ToString() Sep 24, 2025
kundadebdatta
kundadebdatta previously approved these changes Sep 25, 2025
@kundadebdatta kundadebdatta added the auto-merge Enables automation to merge PRs label Sep 25, 2025
Pilchie
Pilchie previously approved these changes Sep 25, 2025
Copy link
Member

@Pilchie Pilchie left a 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.

@FabianMeiswinkel FabianMeiswinkel merged commit e21f50c into master Sep 25, 2025
27 checks passed
@FabianMeiswinkel FabianMeiswinkel deleted the users/fabianm/fix-icm-663334029 branch September 25, 2025 19:41
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

Labels

auto-merge Enables automation to merge PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants