Merge requests not being updated due to broken MergeRequest#reload_diff
I am seeing a high rate of incidents of merge request diffs not being updated, possibly due to this Sentry error:
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "merge_request_diffs_merge_request_id_key"
DETAIL: Key (merge_request_id)=(746729) already exists.
from active_record/connection_adapters/postgresql_adapter.rb:602:in `exec_prepared'
from active_record/connection_adapters/postgresql_adapter.rb:602:in `block in exec_cache'
from active_record/connection_adapters/abstract_adapter.rb:484:in `block in log'
from active_support/notifications/instrumenter.rb:20:in `instrument'
from active_record/connection_adapters/abstract_adapter.rb:478:in `log'
from active_record/connection_adapters/postgresql_adapter.rb:601:in `exec_cache'
from active_record/connection_adapters/postgresql_adapter.rb:585:in `execute_and_clear'
from active_record/connection_adapters/postgresql/database_statements.rb:160:in `exec_query'
from active_record/connection_adapters/postgresql/database_statements.rb:192:in `exec_insert'
from active_record/connection_adapters/abstract/database_statements.rb:108:in `insert'
from active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
from active_record/relation.rb:64:in `insert'
from active_record/persistence.rb:524:in `_create_record'
from active_record/counter_cache.rb:139:in `_create_record'
from config/initializers/ar_monkey_patch.rb:12:in `_create_record'
from active_record/attribute_methods/dirty.rb:133:in `_create_record'
from active_record/callbacks.rb:306:in `block in _create_record'
from active_support/callbacks.rb:117:in `call'
from active_support/callbacks.rb:555:in `block (2 levels) in compile'
from active_support/callbacks.rb:505:in `call'
from active_support/callbacks.rb:92:in `__run_callbacks__'
https://sentry.gitlap.com/gitlab/gitlabcom/issues/11440/
@ernstvn also had an issue today updating this MR: gitlab-com/www-gitlab-com!3114 (merged)
Twitter user: https://twitter.com/daslicious/status/775826293602430976