Skip to content

Fix race condition in Orleans shopping cart inventory#7122

Open
TimonPasslick wants to merge 2 commits into
dotnet:mainfrom
TimonPasslick:issue#7121-fix-race-condition-in-orleans-shopping-cart-inventory
Open

Fix race condition in Orleans shopping cart inventory#7122
TimonPasslick wants to merge 2 commits into
dotnet:mainfrom
TimonPasslick:issue#7121-fix-race-condition-in-orleans-shopping-cart-inventory

Conversation

@TimonPasslick

Copy link
Copy Markdown

Summary

A dictionary gets filled in a parallel for loop without protection, so I added locking.

Fixes #7121

)

dictionary filled in parallel for loop, added locking
@TimonPasslick TimonPasslick requested a review from a team as a code owner June 23, 2026 18:12
@TimonPasslick TimonPasslick changed the title fix race condition in Orleans shopping cart inventory (issue #7121) Fix race condition in Orleans shopping cart inventory Jun 23, 2026
return;
}

object lockObject = new();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd prefer seeing the lock object be a System.Threading.Lock type.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cool, I didn't know about this explicit lock type. Fixed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in orleans/ShoppingCart/Grains/InventoryGrain.cs#L48

2 participants