platformplatform / PlatformPlatform

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
257 stars 26 forks source link

Fix race condition leading to UnitOfWork not being committed #574

Closed PavlovicDzFilip closed 2 months ago

PavlovicDzFilip commented 2 months 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 2 months ago

CLA assistant check
All committers have signed the CLA.