platformplatform / PlatformPlatform

🚀 Pre-alpha state. A platform designed for building enterprise-grade, multi-tenant products using Azure, .NET, React, TypeScript, Infrastructure as Code, etc.
https://platformplatform.github.io
MIT License
250 stars 27 forks source link

Fix race condition leading to UnitOfWork not being committed #574

Closed PavlovicDzFilip closed 1 month ago

PavlovicDzFilip commented 1 month ago

Summary & Motivation

In rare conditions, the code allows the unit of work and/or the events to not be published at the end of the request.

Multiple threads can decrement the concurrent counter at the same time using Interlocked to ensure atomicity of the operation. However, when reading the data, Interlocked was not used, leading to potential race conditions.

Checklist

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.