Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurencyFailure at SetAuthenticationTokenAsync #73

Open
IgorMenshikov opened this issue Sep 10, 2024 · 0 comments
Open

ConcurencyFailure at SetAuthenticationTokenAsync #73

IgorMenshikov opened this issue Sep 10, 2024 · 0 comments

Comments

@IgorMenshikov
Copy link

My NETCore 8 app. It works with Posgress database and has the code:

        var userManager = instance of UserManager<IdentityUser>
        var user = await userManager.FindByEmailAsync(parameters.Email);

        var resetCode = await userManager.GeneratePasswordResetTokenAsync(user);
        var result = userManager.SetAuthenticationTokenAsync(user, "demo", "demo", resetCode);

SetAuthenticationTokenAsync returns ConcurencyFailure in some random situations.

I have checked application logs. In normal situations it is like:

Executed DbCommand (8ms) [Parameters=[@p1='?', @p2='?', @p3='?', @p0='?', @p18='?', @p4='?' (DbType = Int32), @p5='?', @p19='?', @p6='?', @p7='?' (DbType = Boolean), @p8='?' (DbType = Boolean), @p9='?' (DbType = DateTimeOffset), @p10='?', @p11='?', @p12='?', @p13='?', @p14='?' (DbType = Boolean), @p15='?', @p16='?' (DbType = Boolean), @p17='?'], CommandType='Text', CommandTimeout='30']
2024-09-10T18:18:58.8912872Z       UPDATE "AspNetUserTokens" SET "Value" = @p0
2024-09-10T18:18:58.8912915Z       WHERE "LoginProvider" = @p1 AND "Name" = @p2 AND "UserId" = @p3;
2024-09-10T18:18:58.8912973Z       UPDATE "AspNetUsers" SET "AccessFailedCount" = @p4, "ConcurrencyStamp" = @p5, "Email" = @p6, "EmailConfirmed" = @p7, "LockoutEnabled" = @p8, "LockoutEnd" = @p9, "NormalizedEmail" = @p10, "NormalizedUserName" = @p11, "PasswordHash" = @p12, "PhoneNumber" = @p13, "PhoneNumberConfirmed" = @p14, "SecurityStamp" = @p15, "TwoFactorEnabled" = @p16, "UserName" = @p17
2024-09-10T18:18:58.8913009Z       WHERE "Id" = @p18 AND "ConcurrencyStamp" = @p19;

If the calls fails, I see two AspNetUsers updates for some reason:

2024-09-10T18:05:47.3729525Z info: Microsoft.EntityFrameworkCore.Database.Command[20101]
2024-09-10T18:05:47.3733480Z       Executed DbCommand (9ms) [Parameters=[@p1='?', @p2='?', @p3='?', @p0='?', @p18='?', @p4='?' (DbType = Int32), @p5='?', @p19='?', @p6='?', @p7='?' (DbType = Boolean), @p8='?' (DbType = Boolean), @p9='?' (DbType = DateTimeOffset), @p10='?', @p11='?', @p12='?', @p13='?', @p14='?' (DbType = Boolean), @p15='?', @p16='?' (DbType = Boolean), @p17='?', @p34='?', @p20='?' (DbType = Int32), @p21='?', @p35='?', @p22='?', @p23='?' (DbType = Boolean), @p24='?' (DbType = Boolean), @p25='?' (DbType = DateTimeOffset), @p26='?', @p27='?', @p28='?', @p29='?', @p30='?' (DbType = Boolean), @p31='?', @p32='?' (DbType = Boolean), @p33='?'], CommandType='Text', CommandTimeout='30']
2024-09-10T18:05:47.3733562Z       UPDATE "AspNetUserTokens" SET "Value" = @p0
2024-09-10T18:05:47.3733602Z       WHERE "LoginProvider" = @p1 AND "Name" = @p2 AND "UserId" = @p3;
2024-09-10T18:05:47.3733658Z       UPDATE "AspNetUsers" SET "AccessFailedCount" = @p4, "ConcurrencyStamp" = @p5, "Email" = @p6, "EmailConfirmed" = @p7, "LockoutEnabled" = @p8, "LockoutEnd" = @p9, "NormalizedEmail" = @p10, "NormalizedUserName" = @p11, "PasswordHash" = @p12, "PhoneNumber" = @p13, "PhoneNumberConfirmed" = @p14, "SecurityStamp" = @p15, "TwoFactorEnabled" = @p16, "UserName" = @p17
2024-09-10T18:05:47.3733695Z       WHERE "Id" = @p18 AND "ConcurrencyStamp" = @p19;
2024-09-10T18:05:47.3733766Z       UPDATE "AspNetUsers" SET "AccessFailedCount" = @p20, "ConcurrencyStamp" = @p21, "Email" = @p22, "EmailConfirmed" = @p23, "LockoutEnabled" = @p24, "LockoutEnd" = @p25, "NormalizedEmail" = @p26, "NormalizedUserName" = @p27, "PasswordHash" = @p28, "PhoneNumber" = @p29, "PhoneNumberConfirmed" = @p30, "SecurityStamp" = @p31, "TwoFactorEnabled" = @p32, "UserName" = @p33
2024-09-10T18:05:47.3733803Z       WHERE "Id" = @p34 AND "ConcurrencyStamp" = @p35;

For sure the second update fails but I cannot understand library executes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant