-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
Description
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.