Hello,
We are experiencing serious problems with connection leak/ not closed transactions. (System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.) The problem is occuring on production environment under higher load. There are lots of connections open and not closed after the requests and application becomes frozen. After out investigation we discovered that there is probably a problem with AsyncHelper.RunSync which is used in many places in the system and aspnetboilerplate libaries. I would like to share our solution and node application that runs reuests in parallel. With that you can reproduce the problem on your machines.
Product version: ASP.NET CORE & Angular, .NET 5.0, v10.2.0
In attached solution you can find:
How to run this tests?
npm init -y
and install the 3 dependencies: npm i async newman path
We can see that collections for WorkingGood1 and WorkingGood2 works properly.
When we run WorkingBad endpoint collection the transactions and connections are not closing and application is frozen. We can check that by running scripts in Management Studio from sql-scripts directory.
Please check attached solution and attached presentation video. Video Solution