-
Notifications
You must be signed in to change notification settings - Fork 376
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
Duplicate visit_token - ahoy_matey (1.0.2) #34
Comments
Does this only happen occasionally? Also, what version of Rails are you on? I believe Rails now throws an |
Rails 4.1.4 |
With postgres I get PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "visits_pkey" DETAIL: Key (id)=(the-key) already exists. |
Probably related to #32 - can you tell if it's trying to insert a |
Any solution to this? I've got thousands of these errors a day right now. |
Still need more info to debug (not seeing it in any of my setups). Do you have the parameters passed to the /ahoy/visits endpoint? |
I am also getting a similar error (primary key is duplicate). It happens when I refresh a page for which the visit duration is over. Was wondering why that is happening. Visit id is not nil but one that is already in the table. |
It's because he's rescuing the creation of the visit and then doing nothing in order to skip the duplicate object error. |
But the visit duration is over. Shouldn't it create a new visit ? |
I'm experiencing this too. It seems that if the visit duration is exceeded the next updates sent back to the server cause duplicate key errors on the id(UUID) field on the events table. I can't find any instances of this happening recently for the visits table. |
I figured this out - the migration for visits creates a binary(16) field for visit_id (and visitor_id) in sql server. This field is not big enough to accommodate the 36 char long UUID (thus losing it's uniqueness). Changed the field to varbinary(max) and it is working now. |
Well using PostgreSQL and the generated migrations my column types are uuid, so I don't think that's the same issue I am seeing. |
Same here on PostgreSQL and the column types being uuid. |
I'm thinking that it is some problem with the JS tracking code. I managed to get this to re-produce on my local development machine and when I set a breakpoint in the client side JS I can see that all the events that are causing the duplicate ID's are still in the queue client side, even though a matching event already exists in the database. So perhaps something isn't clearing them out of the queue after they are sent to the server? |
@sheetalank Interesting, 16 bytes is all that's needed to store a UUID. @mchristen Events aren't removed from the queue until the server gives a successful response, so it's expected that events can be sent multiple times. The store should gracefully handle this situation, but maybe this line needs updated? |
Well I guess I am wondering how the events can be populated already in the database without the client side receiving a success code indicating it should remove the event from the queue. So either the event is never being removed the queue after being successfully added to the database server side, or the same event is being re-created and re-queued client side after it has already been sent to the server and processed(and removed from the client side queue). |
I'm having the same problem. PG::Error: ERROR: duplicate key value violates unique constraint "visits_pkey"
DETAIL: Key (id)=(b9f96737-a1b5-4990-ba4f-6956c7e04e24) already exists.
: INSERT INTO "visits" ("browser", "country", "device_type", "id", "ip", "landing_page", "os", "started_at", "user_agent", "visitor_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id" |
Having this problem as well. Has anyone found a reasonable solution? |
Same issue here with pg 9.3.5 and rails 4.1.8 |
Having this same issue. Is there any way we can solve it? |
Same issue here with ahoy_matey 1.2.0, rails 4.2.3, pg 9.4.2. @ankane I dug into the source code and noticed that You borrowed the
http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript/2117523#2117523 I suppose we need a more robust UUID generator in client-side. Or generate UUID on server-side. |
Same issue here:
Do anyone find any solution? |
I am having a similar issue, any new development? What's the deal with PR #44? |
Same issue here, it happens when tracks visits across subdomains. seems like in ahoy.js, in https://github.com/ankane/ahoy/blob/master/vendor/assets/javascripts/ahoy.js#L146
|
Cleaning up issues. Feel free to reopen or create a new issue if someone is still seeing this on the latest version and interested in helping to debug. |
Just ran into this issue for tracking_events. |
@GlombSt Can you create a gist with the full error and relevant backtrace? |
FYI, still getting this type of error after moving to v1.0.2
Mysql2::Error: Duplicate entry 'ecf37acb-ef0d-4f5f-b536-093c3a899868' for key 'index_visits_on_visit_token': INSERT INTO
visits
(browser
,cf_connecting_ip
,country
,created_at
,device_type
,ip
,landing_page
,os
,platform
,user_agent
,utm_campaign
,utm_medium
,utm_source
,visit_token
,visitor_token
) VALUES ('IE', '1.2.3.4', 'US', '2014-07-31 06:26:27', 'Desktop', '1.2.3.4', 'https://example.com/';, 'Windows 7', 'Web', 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko', 'xx', 'yy-under', 'zz', 'ecf37acb-ef0d-4f5f-b536-093c3a899868', 'd57022c6-7748-490d-825f-0cbda451b845')The text was updated successfully, but these errors were encountered: