You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this code implemented, and I have connection leaks.
The Dapper Server works fine for some time, but then I suddenly start getting a series of thread pool errors. I recycle the app, and it then works fine, for some time, until the cycle starts again. If I recycle on a regular basis, it never happens, but then, I would prefer to keep it up 24x7.
With only 1 user on (me), I quickly see 48 processes hanging in SQL server, the same 3 queries over and over again. I am sure this is coming from my keep alive check. I implemented the standard Identity 4 client in Angular and kept all default options. https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.4.1/oidc-client.min.js
#1 GetRolesByUserIdQuery
(@userid int)SELECT [Name] FROM [dbo].[tblIdentityRole], [dbo].[tblIdentityUserRole] WHERE [UserId] = @userid AND [dbo].[tblIdentityRole].[Id] = [dbo].[tblIdentityUserRole].[RoleId]
#2 SelectRoleByNameQuery
(@name nvarchar(4000))SELECT * FROM [dbo].[tblIdentityRole] WHERE [Name] = @name
#3 SelectClaimByRoleQuery
(@RoleId int)SELECT [dbo].[tblIdentityRoleClaim].* FROM [dbo].[tblIdentityRole], [dbo].[tblIdentityRoleClaim] WHERE [RoleId] = @RoleId AND [dbo].[tblIdentityRoleClaim].[RoleId] = [dbo].[tblIdentityRole].[Id]
Here is a sample from my log:
[23:30:31 Error] Identity.Dapper.Repositories.RoleRepository
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.
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.
at System.Data.Common.ADP.ExceptionWithStackTrace(Exception e)
--- End of stack trace from previous location where exception was thrown ---
at Identity.Dapper.Repositories.RoleRepository`4.GetClaimsByRole(TRole role, CancellationToken cancellationToken) in C:\Source\Identity4Server\Identity.Dapper\Repositories\RoleRepository.cs:line 142
[23:30:31 Error] Identity.Dapper.Stores.DapperRoleStore
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.
[23:30:31 Information] IdentityServer4.Events.DefaultEventService
{
"Name": "Unhandled Exception",
"Category": "Error",
"EventType": "Error",
"Id": 3000,
"Details": "System.ArgumentNullException: Value cannot be null.\r\nParameter name: claims\r\n at System.Security.Claims.ClaimsIdentity.AddClaims(IEnumerable1 claims)\r\n at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory2.GenerateClaimsAsync(TUser user)\r\n at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory1.CreateAsync(TUser user)\r\n at IdentityServer4.AspNetIdentity.UserClaimsFactory1.CreateAsync(TUser user) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\UserClaimsFactory.cs:line 28\r\n at STSProject.Controllers.Account.CustomProfileService.GetProfileDataAsync(ProfileDataRequestContext context) in C:\Source\Identity4Server\STSProject\Controllers\CustomProfile\CustomProfileService.cs:line 26\r\n at IdentityServer4.ResponseHandling.UserInfoResponseGenerator.ProcessAsync(UserInfoRequestValidationResult validationResult) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\UserInfoResponseGenerator.cs:line 79\r\n at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessUserInfoRequestAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 89\r\n at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 60\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54",
"Message": "Value cannot be null.\r\nParameter name: claims",
"ActivityId": "0HLISOTPAATCC:00000003",
"TimeStamp": "2018-12-08T05:30:31Z",
"ProcessId": 23708,
"LocalIpAddress": "::1:4242",
"RemoteIpAddress": "::1"
}
[23:30:31 Fatal] IdentityServer4.Hosting.IdentityServerMiddleware
Unhandled exception: Value cannot be null.
Parameter name: claims
System.ArgumentNullException: Value cannot be null.
Parameter name: claims
at System.Security.Claims.ClaimsIdentity.AddClaims(IEnumerable1 claims) at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory2.GenerateClaimsAsync(TUser user)
at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory1.CreateAsync(TUser user) at IdentityServer4.AspNetIdentity.UserClaimsFactory1.CreateAsync(TUser user) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\UserClaimsFactory.cs:line 28
at STSProject.Controllers.Account.CustomProfileService.GetProfileDataAsync(ProfileDataRequestContext context) in C:\Source\Identity4Server\STSProject\Controllers\CustomProfile\CustomProfileService.cs:line 26
at IdentityServer4.ResponseHandling.UserInfoResponseGenerator.ProcessAsync(UserInfoRequestValidationResult validationResult) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\UserInfoResponseGenerator.cs:line 79
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessUserInfoRequestAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 89
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 60
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54
[23:30:31 Error] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware
An unhandled exception has occurred while executing the request.
System.ArgumentNullException: Value cannot be null.
Parameter name: claims
at System.Security.Claims.ClaimsIdentity.AddClaims(IEnumerable1 claims) at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory2.GenerateClaimsAsync(TUser user)
at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory1.CreateAsync(TUser user) at IdentityServer4.AspNetIdentity.UserClaimsFactory1.CreateAsync(TUser user) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\UserClaimsFactory.cs:line 28
at STSProject.Controllers.Account.CustomProfileService.GetProfileDataAsync(ProfileDataRequestContext context) in C:\Source\Identity4Server\STSProject\Controllers\CustomProfile\CustomProfileService.cs:line 26
at IdentityServer4.ResponseHandling.UserInfoResponseGenerator.ProcessAsync(UserInfoRequestValidationResult validationResult) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\UserInfoResponseGenerator.cs:line 79
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessUserInfoRequestAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 89
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 60
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 69
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\BaseUrlMiddleware.cs:line 36
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Joonasw.AspNetCore.SecurityHeaders.Csp.CspMiddleware.Invoke(HttpContext context)
at STSProject.Startup.<>c.<b__8_0>d.MoveNext() in C:\Source\Identity4Server\STSProject\Startup.cs:line 119
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
[23:30:31 Debug] IdentityServer4.Hosting.CorsPolicyProvider
CORS request made for path: /Home/Error from origin: http://localhost:4200 but was ignored because path was not for an allowed IdentityServer CORS endpoint
[23:30:51 Error] Identity.Dapper.Repositories.UserRepository
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.
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.
at System.Data.Common.ADP.ExceptionWithStackTrace(Exception e)
--- End of stack trace from previous location where exception was thrown ---
at Identity.Dapper.Repositories.UserRepository`7.GetByIdAsync(TKey id) in C:\Source\Identity4Server\Identity.Dapper\Repositories\UserRepository.cs:line 133
The text was updated successfully, but these errors were encountered:
Did you managed to find anything? I guess that all the disposals are made by the internal IoC. But maybe i'm not using connections properly.
I'm not having too much time (you can guess by the time i took to answer your question) to work on this, but i'll be very appreciated if you can find something on the code and make a pull request.
As much as it pains me to say this, I had no choice but to abandon
identity.dapper. When I went to Identity.EF, the problem completely went
away.
Sadly, that's like moving from a Ferari, to a Rube Goldberg inspired
Edsel.
On Tue, Feb 19, 2019 at 2:20 PM Nicolas Grandchamp ***@***.***> wrote:
Did you managed to find anything? I guess that all the disposals are made
by the internal IoC. But maybe i'm not using connections properly.
I'm not having too much time (you can guess by the time i took to answer
your question) to work on this, but i'll be very appreciated if you can
find something on the code and make a pull request.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#80 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC4z-ARBI-Sp-4cB2idxl12Ld0dkRmY1ks5vPFyjgaJpZM4ZJetE>
.
I have this code implemented, and I have connection leaks.
The Dapper Server works fine for some time, but then I suddenly start getting a series of thread pool errors. I recycle the app, and it then works fine, for some time, until the cycle starts again. If I recycle on a regular basis, it never happens, but then, I would prefer to keep it up 24x7.
With only 1 user on (me), I quickly see 48 processes hanging in SQL server, the same 3 queries over and over again. I am sure this is coming from my keep alive check. I implemented the standard Identity 4 client in Angular and kept all default options.
https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.4.1/oidc-client.min.js
#1 GetRolesByUserIdQuery
(@userid int)SELECT [Name] FROM [dbo].[tblIdentityRole], [dbo].[tblIdentityUserRole] WHERE [UserId] = @userid AND [dbo].[tblIdentityRole].[Id] = [dbo].[tblIdentityUserRole].[RoleId]
#2 SelectRoleByNameQuery
(@name nvarchar(4000))SELECT * FROM [dbo].[tblIdentityRole] WHERE [Name] = @name
#3 SelectClaimByRoleQuery
(@RoleId int)SELECT [dbo].[tblIdentityRoleClaim].* FROM [dbo].[tblIdentityRole], [dbo].[tblIdentityRoleClaim] WHERE [RoleId] = @RoleId AND [dbo].[tblIdentityRoleClaim].[RoleId] = [dbo].[tblIdentityRole].[Id]
Here is a sample from my log:
[23:30:31 Error] Identity.Dapper.Repositories.RoleRepository
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.
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.
at System.Data.Common.ADP.ExceptionWithStackTrace(Exception e)
--- End of stack trace from previous location where exception was thrown ---
at Identity.Dapper.Repositories.RoleRepository`4.GetClaimsByRole(TRole role, CancellationToken cancellationToken) in C:\Source\Identity4Server\Identity.Dapper\Repositories\RoleRepository.cs:line 142
[23:30:31 Error] Identity.Dapper.Stores.DapperRoleStore
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.
[23:30:31 Information] IdentityServer4.Events.DefaultEventService
{
"Name": "Unhandled Exception",
"Category": "Error",
"EventType": "Error",
"Id": 3000,
"Details": "System.ArgumentNullException: Value cannot be null.\r\nParameter name: claims\r\n at System.Security.Claims.ClaimsIdentity.AddClaims(IEnumerable
1 claims)\r\n at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory
2.GenerateClaimsAsync(TUser user)\r\n at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory1.CreateAsync(TUser user)\r\n at IdentityServer4.AspNetIdentity.UserClaimsFactory
1.CreateAsync(TUser user) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\UserClaimsFactory.cs:line 28\r\n at STSProject.Controllers.Account.CustomProfileService.GetProfileDataAsync(ProfileDataRequestContext context) in C:\Source\Identity4Server\STSProject\Controllers\CustomProfile\CustomProfileService.cs:line 26\r\n at IdentityServer4.ResponseHandling.UserInfoResponseGenerator.ProcessAsync(UserInfoRequestValidationResult validationResult) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\UserInfoResponseGenerator.cs:line 79\r\n at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessUserInfoRequestAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 89\r\n at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 60\r\n at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54","Message": "Value cannot be null.\r\nParameter name: claims",
"ActivityId": "0HLISOTPAATCC:00000003",
"TimeStamp": "2018-12-08T05:30:31Z",
"ProcessId": 23708,
"LocalIpAddress": "::1:4242",
"RemoteIpAddress": "::1"
}
[23:30:31 Fatal] IdentityServer4.Hosting.IdentityServerMiddleware
Unhandled exception: Value cannot be null.
Parameter name: claims
System.ArgumentNullException: Value cannot be null.
Parameter name: claims
at System.Security.Claims.ClaimsIdentity.AddClaims(IEnumerable
1 claims) at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory
2.GenerateClaimsAsync(TUser user)at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory
1.CreateAsync(TUser user) at IdentityServer4.AspNetIdentity.UserClaimsFactory
1.CreateAsync(TUser user) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\UserClaimsFactory.cs:line 28at STSProject.Controllers.Account.CustomProfileService.GetProfileDataAsync(ProfileDataRequestContext context) in C:\Source\Identity4Server\STSProject\Controllers\CustomProfile\CustomProfileService.cs:line 26
at IdentityServer4.ResponseHandling.UserInfoResponseGenerator.ProcessAsync(UserInfoRequestValidationResult validationResult) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\UserInfoResponseGenerator.cs:line 79
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessUserInfoRequestAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 89
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 60
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54
[23:30:31 Error] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware
An unhandled exception has occurred while executing the request.
System.ArgumentNullException: Value cannot be null.
Parameter name: claims
at System.Security.Claims.ClaimsIdentity.AddClaims(IEnumerable
1 claims) at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory
2.GenerateClaimsAsync(TUser user)at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory
1.CreateAsync(TUser user) at IdentityServer4.AspNetIdentity.UserClaimsFactory
1.CreateAsync(TUser user) in C:\local\identity\server4\AspNetIdentity\src\IdentityServer4.AspNetIdentity\UserClaimsFactory.cs:line 28at STSProject.Controllers.Account.CustomProfileService.GetProfileDataAsync(ProfileDataRequestContext context) in C:\Source\Identity4Server\STSProject\Controllers\CustomProfile\CustomProfileService.cs:line 26
at IdentityServer4.ResponseHandling.UserInfoResponseGenerator.ProcessAsync(UserInfoRequestValidationResult validationResult) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\ResponseHandling\UserInfoResponseGenerator.cs:line 79
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessUserInfoRequestAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 89
at IdentityServer4.Endpoints.UserInfoEndpoint.ProcessAsync(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Endpoints\UserInfoEndpoint.cs:line 60
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 54
at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 69
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in C:\local\identity\server4\IdentityServer4\src\IdentityServer4\Hosting\BaseUrlMiddleware.cs:line 36
at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Joonasw.AspNetCore.SecurityHeaders.Csp.CspMiddleware.Invoke(HttpContext context)
at STSProject.Startup.<>c.<b__8_0>d.MoveNext() in C:\Source\Identity4Server\STSProject\Startup.cs:line 119
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
[23:30:31 Debug] IdentityServer4.Hosting.CorsPolicyProvider
CORS request made for path: /Home/Error from origin: http://localhost:4200 but was ignored because path was not for an allowed IdentityServer CORS endpoint
[23:30:51 Error] Identity.Dapper.Repositories.UserRepository
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.
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.
at System.Data.Common.ADP.ExceptionWithStackTrace(Exception e)
--- End of stack trace from previous location where exception was thrown ---
at Identity.Dapper.Repositories.UserRepository`7.GetByIdAsync(TKey id) in C:\Source\Identity4Server\Identity.Dapper\Repositories\UserRepository.cs:line 133
The text was updated successfully, but these errors were encountered: