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

ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_posts_on_topic... #174

Open
sentry-io bot opened this issue May 1, 2019 · 0 comments
Labels
bug Something isn't working priority: low

Comments

@sentry-io
Copy link

sentry-io bot commented May 1, 2019

Sentry Issue: DISCOURSE-12

PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_posts_on_topic_id_and_post_number"
DETAIL:  Key (topic_id, post_number)=(2425, 21) already exists.

  lib/post_creator.rb:489:in `save_post'
    saved = @post.save
  lib/post_creator.rb:171:in `block in create'
    save_post
  lib/post_creator.rb:343:in `block (2 levels) in transaction'
    blk.call
  lib/post_creator.rb:342:in `block in transaction'
    Post.transaction do
  lib/distributed_mutex.rb:40:in `synchronize'
    yield
...
(135 additional frame(s) were not displayed)

ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_posts_on_topic_id_and_post_number"
DETAIL:  Key (topic_id, post_number)=(2425, 21) already exists.
: INSERT INTO "posts" ("user_id", "topic_id", "post_number", "raw", "cooked", "created_at", "updated_at", "post_type", "sort_order", "last_editor_id", "last_version_at", "word_count", "baked_at", "baked_version", "action_code") VALUES (-1, 2425, 21, '', '', '2019-05-01 16:50:13.759609', '2019-05-01 16:50:13.759609', 3, 21, -1, '2019-05-01 16:50:13.829034', 0, '2019-05-01 16:50:13.759553', 2, 'invited_user') RETURNING "id"

ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_posts_on_topic_id_and_post_number"
DETAIL:  Key (topic_id, post_number)=(2425, 21) already exists.
: INSERT INTO "posts" ("user_id", "topic_id", "post_number", "raw", "cooked", "created_at", "updated_at", "post_type", "sort_order", "last_editor_id", "last_version_at", "word_count", "baked_at", "baked_version", "action_code") VALUES (-1, 2425, 21, '', '', '2019-05-01 16:50:13.759609', '2019-05-01 16:50:13.759609', 3, 21, -1, '2019-05-01 16:50:13.829034', 0, '2019-05-01 16:50:13.759553', 2, 'invited_user') RETURNING "id"

This error happens on the Discourse side when we assign an Admin to a Dispute in the Tools backend.

Looks like we are using an add instead of a upsert and we are sending the payload of all admins instead of the diff of the new ones.

This looks like doesn't prevent admins to be added, so we can tag it as low priority.

Acceptance Criteria

  • When you assign an Admin to a Dispute, Discourse doesn't throw an error.
@orlando orlando added bug Something isn't working priority: low labels May 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: low
Projects
None yet
Development

No branches or pull requests

1 participant