ActiveRecord::RecordNotUnique on idx_tag_users_ix1: How to fix?

Continuing the discussion from SSO Broken - The requested URL or resource could not be found:

I have a similar issue:

ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "idx_tag_users_ix1"

Any idea how to remove the duplicate key?

I think it’s because you have tags that are mixed case (you have tag and Tag).

Is this happening on a rebuild or some other time?

I think the thing to do is to try to rebuild the index and then either fix the case of the tags (if I’m right about that) or just delete one of the duplicate entries.

1 Like

Hmmm… Hardly the case.

=> ["welcome",

Apparently it appeared earlier this month. I suppose it was after an upgrade.

I don’t know how it came to be, but I could remove duplicate tags:

TagUser.all.where(user_id: 80, tag_id:2).last.destroy

For each duplicate (did it manually).

Thanks Jay!

Note that the symptom is cleared, but the cause is not clear at all.

:thinking: I suspect that group notifications on tags, when applied retroactively, do not check for existing entries @pfaffman

1 Like

That’s usually the case on these duplicate whatever issues.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.