aspnet / Identity

[Archived] ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
1.96k stars 868 forks source link

Duplicate queries - Identity and EF Code First #392

Closed greerde closed 9 years ago

greerde commented 9 years ago

I was using Glimpse to check up on the performance of a few pages in my app (MVC5, EF6 Code First, newest Identity).

This is a glimpse snapshot from one of my normal pages right now:

screen shot 2015-03-08 at 11 52 50 am

An hour or so later, I was back and checking on things again. However, this time I noticed Glimpse was reporting this:

screen shot 2015-03-08 at 1 31 16 pm

Nothing had changed on the server - no data or code. Notice the number of queries jumped from 20 to 43.

A quick look into those queries revealed that there are a bunch of Identity tables being queried multiple times (all duplicates of each other).

For example, instead of this query getting excited once, it now gets excited about 4 or 5 times:

screen_shot_2015-03-08_at_1_31_39_pm

Same with this:

screen_shot_2015-03-08_at_1_32_11_pm

The AspNetUsers and AspNetUserLogins also gets queried multiple times.

Browsing ANY page on the site has all of these extra queries, even a completely empty controller and view (with no authentication required). Once the extra queries are there, they don't seem to go away until a logout.

If I log out and log back in, I am back to the normal operation. I was able to repeat this on my production server and development computer - both seem to be triggered by a period of inactivity (session related?).

Thoughts?

divega commented 9 years ago

It seems to me that you are describing this issue: CodePlex #2508 GetClaimsAsync() invoked on every request after identity was regenerated.

It is an unintended regression we introduced in cookie validation in Identity 2.2. We should be releasing a patch with the fix soon.

greerde commented 9 years ago

Is there any update on this? @suhasj @rustd

I just updated to the latest and greatest Identity Nuget packages. I am setting getting very high query counts with most being repeats.

greerde commented 9 years ago

@divega

HaoK commented 9 years ago

Gitthub is for identity 3+, please dicuss Identity 2.x issues on codeplex

rustd commented 9 years ago

This was fixed in ASP.NET Identity 2.2.1 Please make sure you are using the latest version and open an issue on http://aspnetidentity.codeplex.com/ if it still reproes for you