Same UserId Being Reused By Different Anonymous Sessions
Posted: Wed Nov 06, 2019 2:33 pm
So I've run into this several times over the past few years and it was strange but never caused a real "problem" for us until recently. What seems to be happening is that, sometimes, a given UserId will get assigned to an anonymous visitor, and that same UserId will also get assigned to a different anonymous visitor, so when you review the ac_PageViews table you will see a bunch of records that have the same UserId, but different IP Addresses, User Agents, etc. Further, this only seems to happen on the initial request. If a subsequent request is made during the same session a new UserId is issued, which you can see in the attached screen shot from SSMS where I've queried the ac_PageViews table. The two records with black boxes around them are me making two requests. The first request I have the same UserId as all the other anonymous requests (you can see clearly that virtually every record has the same UserId, but they are all different IPs), but then on the very next request I now have a unique UserId.
I am assuming right now that this is the result of a collision caused by two requests coming in at the same time, but then for some reason it keeps reusing the same ID over and over, only issuing a new one when a session makes more than one request. I am assuming this because I haven't been able to reproduce the behavior on my development machine, but it happens on the live server where many, many more requests are being handled at once. Any idea what's going on here, how to fix it, and more importantly: am I going to run into this same problem in the new version (AC9)?
Edit: Attaching the image didn't work. I'm including it here, linked to my google drive instead:
https://drive.google.com/open?id=19ofOs ... 73Sgp5tBwN
Edit 2: Not sure what I was thinking, but it turns out this is actually very easy to reproduce even locally. Just use an incognito (or guest) window. So, basically any time you don't already have cookie information, this is what happens. Possibly an NHibernate caching issue?
I am assuming right now that this is the result of a collision caused by two requests coming in at the same time, but then for some reason it keeps reusing the same ID over and over, only issuing a new one when a session makes more than one request. I am assuming this because I haven't been able to reproduce the behavior on my development machine, but it happens on the live server where many, many more requests are being handled at once. Any idea what's going on here, how to fix it, and more importantly: am I going to run into this same problem in the new version (AC9)?
Edit: Attaching the image didn't work. I'm including it here, linked to my google drive instead:
https://drive.google.com/open?id=19ofOs ... 73Sgp5tBwN
Edit 2: Not sure what I was thinking, but it turns out this is actually very easy to reproduce even locally. Just use an incognito (or guest) window. So, basically any time you don't already have cookie information, this is what happens. Possibly an NHibernate caching issue?