Geo: Merge requests on Secondary should not check mergeable status
In a secondary Geo (#76) node, database is read-only.
If you update your merge request and don't visit the primary node, you would end up with an unchecked merge_status
.
We should not try to solve that in a secondary node, as this will lead to a 500 error because we can't update data on database.
This MR Fixes that:
Started GET "/root/test-project/merge_requests/1" for 189.101.232.69 at 2016-04-28 11:37:28 -0400
Processing by Projects::MergeRequestsController#show as HTML
Parameters: {"namespace_id"=>"root", "project_id"=>"test-project", "id"=>"1"}
Completed 500 Internal Server Error in 372ms (ActiveRecord: 26.9ms)
ActionView::Template::Error (PG::ReadOnlySqlTransaction: ERROR: cannot execute UPDATE in a read-only transaction
: UPDATE "merge_requests" SET "merge_status" = $1 WHERE "merge_requests"."id" = $2):
39: = render "projects/merge_requests/show/how_to_merge"
40: = render "projects/merge_requests/widget/show.html.haml"
41:
42: - if @merge_request.source_branch_exists? && @merge_request.mergeable? && @merge_request.can_be_merged_by?(current_user)
43: .light.prepend-top-default
44: You can also accept this merge request manually using the
45: = succeed '.' do
app/models/merge_request.rb:122:in `call'
app/models/merge_request.rb:122:in `block (2 levels) in <class:MergeRequest>'
app/models/merge_request.rb:272:in `check_if_can_be_merged'
app/models/merge_request.rb:297:in `mergeable?'
app/views/projects/merge_requests/_show.html.haml:42:in `_app_views_projects_merge_requests__show_html_haml__3632812159035673711_50958700'
app/views/projects/merge_requests/show.html.haml:1:in `_app_views_projects_merge_requests_show_html_haml___4126596802437062695_51012840'