Npgsql MaxPoolSize exhausted exception

Dear all,

We are getting the following error on Survey Solutions logs:

---> Npgsql.NpgsqlException (0x80004005): The connection pool has been exhausted, either raise MaxPoolSize (currently 100) or Timeout (currently 15 seconds)

How can we set the Maximum Pool Size connection property in Npgsql from Survey solutions?

Thanks

@arseniy , what is the context in which the error was observed?

Not sure what you mean by context. I attach a piece of logs containing the error. Is this what you meant? the log is in csv format as output by MS Azure, so the the format is slightly different from the standard console log, but it contains the same information.

"TimeGenerated [UTC]",Level,ResultDescription,
"9/17/2022, 10:49:01.489 AM",Informational," [10:49:01 ERR] Headquarters HTTP POST /census/interview/negotiate?interviewId=581a26fac73c44079054d54bad9c8e25&mode=web&negotiateVersion=1 responded 500 in 15590.4730 ms",
"9/17/2022, 10:49:01.489 AM",Informational,"    at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()",
"9/17/2022, 10:49:01.489 AM",Informational,"    at NHibernate.AdoNet.ConnectionManager.GetConnection()",
"9/17/2022, 10:49:01.489 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Implementation.UnitOfWorkInScopeExecutor`1.ExecuteAsync[T](Func`2 action, String workspace) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Implementation/UnitOfWorkInScopeExecutor.cs:line 49",
"9/17/2022, 10:49:01.489 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)",
"9/17/2022, 10:49:01.489 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)",
"9/17/2022, 10:49:01.489 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.489 AM",Informational,"    at Npgsql.NpgsqlConnection.Open()",
"9/17/2022, 10:49:01.489 AM",Informational,"    at NHibernate.Impl.AbstractSessionImpl.BeginTransaction(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:01.489 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.489 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.489 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)",
"9/17/2022, 10:49:01.489 AM",Informational,"    at Microsoft.Extensions.Caching.Memory.CacheExtensions.GetOrCreateAsync[TItem](IMemoryCache cache, Object key, Func`2 factory)",
"9/17/2022, 10:49:01.489 AM",Informational,"    at WB.UI.Headquarters.Code.Workspaces.WorkspaceMiddleware.<>c__DisplayClass2_0.<<Invoke>g__InvokeNextWithScope|0>d.MoveNext() in /src/UI/WB.UI.Headquarters.Core/Code/Workspaces/WorkspaceMiddleware.cs:line 61",
"9/17/2022, 10:49:01.489 AM",Informational,"    at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync()",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.UI.Headquarters.Code.Workspaces.WorkspaceMiddleware.<>c__DisplayClass2_0.<<Invoke>g__InvokeNextWithScope|0>d.MoveNext() in /src/UI/WB.UI.Headquarters.Core/Code/Workspaces/WorkspaceMiddleware.cs:line 61",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.UI.Headquarters.Code.Workspaces.WorkspaceMiddleware.Invoke(HttpContext context) in /src/UI/WB.UI.Headquarters.Core/Code/Workspaces/WorkspaceMiddleware.cs:line 89",
"9/17/2022, 10:49:01.518 AM",Informational,"  ---> Npgsql.NpgsqlException (0x80004005): The connection pool has been exhausted, either raise MaxPoolSize (currently 100) or Timeout (currently 15 seconds)",
"9/17/2022, 10:49:01.518 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.<>c__DisplayClass4_0.<<GetUserWorkspaces>b__0>d.MoveNext() in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 42",
"9/17/2022, 10:49:01.518 AM",Informational,"    at StackExchange.Exceptional.ExceptionalMiddleware.Invoke(HttpContext context)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.GetUserWorkspaces(Guid userId, CancellationToken token) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 43",
"9/17/2022, 10:49:01.518 AM",Informational,"    at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Implementation.UnitOfWorkInScopeExecutor`1.ExecuteAsync[T](Func`2 action, String workspace) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Implementation/UnitOfWorkInScopeExecutor.cs:line 49",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at NHibernate.Connection.DriverConnectionProvider.GetConnection(String connectionString)",
"9/17/2022, 10:49:01.518 AM",Informational," NHibernate.TransactionException: Begin failed with SQL exception",
"9/17/2022, 10:49:01.518 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.<>c__DisplayClass5_0.<<Invoke>g__Next|0>d.MoveNext() in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 41",
"9/17/2022, 10:49:01.518 AM",Informational,"    at NHibernate.Impl.AbstractSessionImpl.BeginTransaction(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)",
"9/17/2022, 10:49:01.518 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.518 AM",Informational,"    at NHibernate.AdoNet.ConnectionManager.GetConnection()",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.Infrastructure.Native.Storage.Postgre.UnitOfWork.<get_Session>b__16_0(String workspace) in /src/Infrastructure/WB.Infrastructure.Native/Storage/Postgre/UnitOfWork.cs:line 90",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Npgsql.NpgsqlConnection.Open()",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Users.HqUserStore.FindByIdAsync(Guid userId, CancellationToken cancellationToken) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Users/HqUserStore.cs:line 56",
"9/17/2022, 10:49:01.518 AM",Informational,"  ---> System.TimeoutException: The operation has timed out.",
"9/17/2022, 10:49:01.518 AM",Informational," [10:49:01 ERR] Headquarters An unhandled exception has occurred, logging to Exceptional",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.Invoke(HttpContext context) in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 92",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.Infrastructure.Native.Storage.Postgre.UnitOfWork.get_Session() in /src/Infrastructure/WB.Infrastructure.Native/Storage/Postgre/UnitOfWork.cs:line 81",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.<>c__DisplayClass4_0.<<GetUserWorkspaces>b__1>d.MoveNext() in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 41",
"9/17/2022, 10:49:01.518 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.518 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.518 AM",Informational,"    --- End of inner exception stack trace ---",
"9/17/2022, 10:49:01.518 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync()",
"9/17/2022, 10:49:01.518 AM",Informational,"    at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at Microsoft.Extensions.Caching.Memory.CacheExtensions.GetOrCreateAsync[TItem](IMemoryCache cache, Object key, Func`2 factory)",
"9/17/2022, 10:49:01.518 AM",Informational,"    at WB.UI.Headquarters.Code.Authentication.HqCookieAuthenticationEvents.ValidatePrincipal(CookieValidatePrincipalContext context) in /src/UI/WB.UI.Headquarters.Core/Code/Authentication/HqCookieAuthenticationEvents.cs:line 132",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()",
"9/17/2022, 10:49:07.418 AM",Informational,"    at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:07.418 AM",Informational,"    at NHibernate.Connection.DriverConnectionProvider.GetConnection(String connectionString)",
"9/17/2022, 10:49:07.418 AM",Informational," [10:49:07 ERR] Headquarters An unhandled exception has occurred while executing the request.",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Microsoft.Extensions.Caching.Memory.CacheExtensions.GetOrCreateAsync[TItem](IMemoryCache cache, Object key, Func`2 factory)",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.<>c__DisplayClass4_0.<<GetUserWorkspaces>b__0>d.MoveNext() in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 42",
"9/17/2022, 10:49:07.418 AM",Informational,"  ---> Npgsql.NpgsqlException (0x80004005): The connection pool has been exhausted, either raise MaxPoolSize (currently 100) or Timeout (currently 15 seconds)",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Implementation.UnitOfWorkInScopeExecutor`1.ExecuteAsync[T](Func`2 action, String workspace) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Implementation/UnitOfWorkInScopeExecutor.cs:line 49",
"9/17/2022, 10:49:07.418 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.418 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)",
"9/17/2022, 10:49:07.418 AM",Informational,"    at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.GetUserWorkspaces(Guid userId, CancellationToken token) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 43",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.Infrastructure.Native.Storage.Postgre.UnitOfWork.<get_Session>b__16_0(String workspace) in /src/Infrastructure/WB.Infrastructure.Native/Storage/Postgre/UnitOfWork.cs:line 90",
"9/17/2022, 10:49:07.418 AM",Informational,"    at NHibernate.Impl.AbstractSessionImpl.BeginTransaction(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:07.418 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()",
"9/17/2022, 10:49:07.418 AM",Informational,"    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.UI.Headquarters.Code.Authentication.HqCookieAuthenticationEvents.ValidatePrincipal(CookieValidatePrincipalContext context) in /src/UI/WB.UI.Headquarters.Core/Code/Authentication/HqCookieAuthenticationEvents.cs:line 132",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.Infrastructure.Native.Storage.Postgre.UnitOfWork.get_Session() in /src/Infrastructure/WB.Infrastructure.Native/Storage/Postgre/UnitOfWork.cs:line 81",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.<>c__DisplayClass5_0.<<Invoke>g__Next|0>d.MoveNext() in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 41",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)",
"9/17/2022, 10:49:07.418 AM",Informational,"    --- End of inner exception stack trace ---",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync()",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.Invoke(HttpContext context) in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 92",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.<>c__DisplayClass4_0.<<GetUserWorkspaces>b__1>d.MoveNext() in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 41",
"9/17/2022, 10:49:07.418 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Users.HqUserStore.FindByIdAsync(Guid userId, CancellationToken cancellationToken) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Users/HqUserStore.cs:line 56",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()",
"9/17/2022, 10:49:07.418 AM",Informational,"  ---> System.TimeoutException: The operation has timed out.",
"9/17/2022, 10:49:07.418 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Npgsql.NpgsqlConnection.Open()",
"9/17/2022, 10:49:07.418 AM",Informational,"    at NHibernate.AdoNet.ConnectionManager.GetConnection()",
"9/17/2022, 10:49:07.418 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)",
"9/17/2022, 10:49:07.418 AM",Informational," NHibernate.TransactionException: Begin failed with SQL exception",
"9/17/2022, 10:49:07.418 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.462 AM",Informational,"    at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.Infrastructure.Native.Storage.Postgre.UnitOfWork.<get_Session>b__16_0(String workspace) in /src/Infrastructure/WB.Infrastructure.Native/Storage/Postgre/UnitOfWork.cs:line 90",
"9/17/2022, 10:49:07.462 AM",Informational," [10:49:07 ERR] Headquarters An exception was thrown attempting to execute the error handler.",
"9/17/2022, 10:49:07.462 AM",Informational," NHibernate.TransactionException: Begin failed with SQL exception",
"9/17/2022, 10:49:07.462 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Users.HqUserStore.FindByIdAsync(Guid userId, CancellationToken cancellationToken) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Users/HqUserStore.cs:line 56",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()",
"9/17/2022, 10:49:07.462 AM",Informational,"  ---> System.TimeoutException: The operation has timed out.",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync()",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at NHibernate.Impl.AbstractSessionImpl.BeginTransaction(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at NHibernate.AdoNet.ConnectionManager.GetConnection()",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.<>c__DisplayClass4_0.<<GetUserWorkspaces>b__0>d.MoveNext() in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 42",
"9/17/2022, 10:49:07.462 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.462 AM",Informational,"    at NHibernate.Connection.DriverConnectionProvider.GetConnection(String connectionString)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.Invoke(HttpContext context) in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 92",
"9/17/2022, 10:49:07.462 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()",
"9/17/2022, 10:49:07.462 AM",Informational,"  ---> Npgsql.NpgsqlException (0x80004005): The connection pool has been exhausted, either raise MaxPoolSize (currently 100) or Timeout (currently 15 seconds)",
"9/17/2022, 10:49:07.462 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Npgsql.NpgsqlConnection.Open()",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.Infrastructure.Native.Storage.Postgre.UnitOfWork.get_Session() in /src/Infrastructure/WB.Infrastructure.Native/Storage/Postgre/UnitOfWork.cs:line 81",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Implementation.UnitOfWorkInScopeExecutor`1.ExecuteAsync[T](Func`2 action, String workspace) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Implementation/UnitOfWorkInScopeExecutor.cs:line 49",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.<>c__DisplayClass4_0.<<GetUserWorkspaces>b__1>d.MoveNext() in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 41",
"9/17/2022, 10:49:07.462 AM",Informational," --- End of stack trace from previous location ---",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Microsoft.Extensions.Caching.Memory.CacheExtensions.GetOrCreateAsync[TItem](IMemoryCache cache, Object key, Func`2 factory)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.Core.BoundedContexts.Headquarters.Workspaces.Impl.WorkspacesUsersCache.GetUserWorkspaces(Guid userId, CancellationToken token) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Workspaces/Impl/WorkspacesUsersCache.cs:line 43",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.UI.Headquarters.Code.Authentication.HqCookieAuthenticationEvents.ValidatePrincipal(CookieValidatePrincipalContext context) in /src/UI/WB.UI.Headquarters.Core/Code/Authentication/HqCookieAuthenticationEvents.cs:line 132",
"9/17/2022, 10:49:07.462 AM",Informational,"    --- End of inner exception stack trace ---",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()",
"9/17/2022, 10:49:07.462 AM",Informational,"    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.<>c__DisplayClass5_0.<<Invoke>g__Next|0>d.MoveNext() in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 41",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)",
"9/17/2022, 10:49:07.462 AM",Informational,"    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)",
"9/17/2022, 10:49:07.497 AM",Informational," --- End of stack trace from previous location ---",

Do you have 100 people working simultaneously with the server when the error occurs? Is the server so slow that can’t process a query within the allotted timeout time?

I am not sure how to check the number of active connections to SuSo application, it seems that Azure is not able to read this info when SuSo is installed using Docker. If we talk about database connections, then for the logs above it is around 170 active connections, BUT we are running a sever farm with SuSo being deployed to a cluster of 3 virtual machines. Each of those has 2 cores and 8GB RAM. For the instance in question, the CPU and RAM usage are around 93% and 74% respectively for the logs above. The database is not even close to the limits with CPU and RAM usage being below 20% and 50% respectively. I cannot tell if more than 100 connections are made through this particular instance, but this seems unlikely. Neither I can tell whether the query can be processed in the allotted time. My guess is that an export job is keeping the instance busy.

If you work in a farm mode and you are expecting a higher volume of simultaneous connections the configurations of DB server and connection strings on clients should be adjusted.
Server:

set param max_connections at least 1000.
Client:
file - appsettings.production.ini
section - [ConnectionStrings]
key - DefaultConnections
param - MaxPoolSize
set value - 500