-
Type: Improvement
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: 2.18.0
-
Component/s: None
-
Labels:
When the number of threads that trie to execute mongodb queries using MongoDb.Driver 2.18, we start to have some threads that hangs for a while (some seconds to 1 minute), then a lot of errors are logged which all point aout the same issue:
2023-11-16 12:05:53.579 +01:00 [ERR] An error occured while publishing message Domain.Events.IDomainEvent MongoDB.Driver.MongoWaitQueueFullException: The wait queue for acquiring a connection to server localhost:27017 is full. at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionHelper.AcquireWaitQueueSlot() at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionHelper.StartCheckingOut() at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionHelper.AcquireConnectionAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.Server.GetChannelAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.RetryableReadContext.InitializeAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.RetryableReadContext.CreateAsync(IReadBinding binding, Boolean retryRequested, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.FindOperation`1.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken) at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperationAsync[TResult](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken) at Compliance.Wastewater.Infrastructure.PlantAnalysisReports.PlantAnalysisReportRepository.GetPlantAnalysisReportPersistentModel(Guid plantId, DateTime samplingStartDate, Guid finalityTypeId)
I tried to set Min and Max connection pool size to different values 100 to 500 but didn't resolve the issue:
I tried also to profile the application to find any long queries but I could not find out any. All the times I did it, The first thing that take time based on DotTrace profiler is the Acquire method of the connection pool (I will add some pictures)