Continuing the discussion from After upgrade to 0.9.9.18: Unknown error saving post, try again. Error: 500 Internal Server Error:
I have started having sporadic errors when posting:
“Unknown error saving post, try again. Error: 500 Internal Server Error”
I am on latest updates as of today. (260b94e) Stock Docker install with New Relic and poll plugins only.
ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_topic_users_on_topic_id_and_user_id" DETAIL: Key (topic_id, user_id)=(697, 3) already exists. : INSERT INTO topic_users(user_id, topic_id, notification_level, notifications_reason_id) SELECT user_id, 697, 3, 6 FROM category_users WHERE notification_level = 3 AND category_id = 5 AND NOT EXISTS(SELECT 1 FROM topic_users WHERE topic_id = 697 AND user_id = category_users.user_id) )
I’m a bit worried that this is self-inflicted ie related to some hacking I did in the Rails console to amend CategoryUser entries in order to make all my users Watch a category by default. But I did this weeks ago and I haven’t had any problems until now. So I’m open to the idea of this being my ill-advised meddling OR a bug.
Incidentally, trying to see if there really is a duplicate entry:
pry(main)> Topic.where(id: 697) =>  pry(main)> TopicUser.where(topic_id:697) => 
Is there any other information that I can supply to help solve this? The backtrace was about 4 screens so haven’t dumped it here but it’s in this pastebin [Ruby] /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.3/lib/pa - Pastebin.com