Plots2: ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '0' for key 'index_node_vid': INSERT INTO `node` (`type`, `title`,...

Created on 17 Mar 2019  路  6Comments  路  Source: publiclab/plots2

Sentry Issue: PLOTS2-2F

Mysql2::Error: Duplicate entry '0' for key 'index_node_vid'
  app/models/node.rb:621:in `block in new_note'
    node.save!
  app/models/node.rb:620:in `new_note'
    ActiveRecord::Base.transaction do
  app/controllers/notes_controller.rb:109:in `create'
    saved, @node, @revision = Node.new_note(uid: current_user.uid,
...
(151 additional frame(s) were not displayed)

ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '0' for key 'index_node_vid': INSERT INTO `node` (`type`, `title`, `uid`, `status`, `changed`, `comment`, `path`, `slug`) VALUES ('note', 'Outreachy proposal: PublicLabs.org UI Improvement', 578767, 4, 1552782418, 2, '/notes/madeofhuman/03-17-2019/outreachy-proposal-publiclabs-org-ui-improvement', 'outreachy-proposal-publiclabs-org-ui-improvement')

ActiveRecord::RecordNotUnique: Mysql2::Error: Duplicate entry '0' for key 'index_node_vid': INSERT INTO `node` (`type`, `title`, `uid`, `status`, `changed`, `comment`, `path`, `slug`) VALUES ('note', 'Outreachy proposal: PublicLabs.org UI Improvement', 578767, 4, 1552782418, 2, '/notes/madeofhuman/03-17-2019/outreachy-proposal-publiclabs-org-ui-improvement', 'outreachy-proposal-publiclabs-org-ui-improvement')
bug help wanted high-priority

All 6 comments

Thanks for opening your first issue! This space is protected by our Code of Conduct - and we're here to help.
Please follow the issue template to help us help you 馃憤馃帀馃槃
If you have screenshots or a gif to share demonstrating the issue, that's really helpful! 馃摳

Not sure why but this is now failing due to non unique vid. We don't assign vid until the next few lines so it's the default that's causing trouble.

https://github.com/publiclab/plots2/blame/master/app/models/node.rb#L621

Could be some error created a vid of 0 and now we can't assign that (even briefly) before getting a new valid vid. Odd because this all happens in a transaction so it should never get stuck in that state.

I'll try to flush an existing node with that vid to see what happens.

I've just found a stray node draft with vid=0 and i changed that. @sagarpreet-chadha i'm not sure how this happened but it was linked to a draft of yours which now seems to be without a revision record (although it had been set to 0, strangely).

It's here: https://publiclab.org/notes/sagarpreet/03-16-2019/gsoc-proposal-lel-2-0-and-work-on-leaflet-blurred-projects but it seems to be a duplicate of your original https://publiclab.org/notes/sagarpreet/03-09-2019/gsoc-proposal-lel-2-0-and-work-on-leaflet-blurred-projects, which seems fine.

So if nothing is wrong with your published proposal, we could delete the draft; maybe we need to look at the draft creation code to see how this came to occur?

If we can test posting a new note now that would be great. I'll alert folks in #5103.

Sentry issue: PLOTS2-2N

Oddly we are still seeing this issue in Sentry as you can see in the last comment here, although I don't know if others are experiencing the issue? New posts have gone up since then...

Closing for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

keshavsethi picture keshavsethi  路  3Comments

noi5e picture noi5e  路  3Comments

shapironick picture shapironick  路  3Comments

first-timers[bot] picture first-timers[bot]  路  3Comments

milaaraujo picture milaaraujo  路  3Comments