Commit 32e45d8c authored by Kamil Trzciński's avatar Kamil Trzciński

EE: Forbid the use of `#reload` and prefer `#reset`

The `#reload` makes to load all objects into memory,
and the main purpose of `#reload` is to drop the association cache.

The `#reset` seems to solve exactly that case.
parent 829d5cd5
...@@ -77,9 +77,9 @@ module VisibleApprovable ...@@ -77,9 +77,9 @@ module VisibleApprovable
end end
def reset_approval_cache! def reset_approval_cache!
approvals.reload approvals.reset
approved_by_users.reload approved_by_users.reset
approval_rules.reload approval_rules.reset
clear_memoization(:approvers_left) clear_memoization(:approvers_left)
clear_memoization(:all_approvers_including_groups) clear_memoization(:all_approvers_including_groups)
......
...@@ -25,7 +25,7 @@ class ProjectFeatureUsage < ApplicationRecord ...@@ -25,7 +25,7 @@ class ProjectFeatureUsage < ApplicationRecord
touch(self.class.jira_dvcs_integration_field(cloud: cloud)) touch(self.class.jira_dvcs_integration_field(cloud: cloud))
end end
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
reload reset
retry retry
end end
end end
...@@ -9,7 +9,7 @@ module ApprovalRules ...@@ -9,7 +9,7 @@ module ApprovalRules
filter_eligible_groups! filter_eligible_groups!
if rule.update(params) if rule.update(params)
rule.reload rule.reset
success success
else else
error(rule.errors.messages) error(rule.errors.messages)
......
...@@ -16,8 +16,8 @@ module CleanupApprovers ...@@ -16,8 +16,8 @@ module CleanupApprovers
# If the target already has `approvers` and/or `approver_groups` loaded then we need to # If the target already has `approvers` and/or `approver_groups` loaded then we need to
# force a reload in order to not return stale information after the destroys above # force a reload in order to not return stale information after the destroys above
if reload if reload
target.approvers.reload target.approvers.reset
target.approver_groups.reload target.approver_groups.reset
end end
target target
......
...@@ -18,7 +18,7 @@ module EE ...@@ -18,7 +18,7 @@ module EE
return unless can?(current_user, :update_epic, epic_issue.epic.group) return unless can?(current_user, :update_epic, epic_issue.epic.group)
epic_issue.update(issue_id: new_entity.id) epic_issue.update(issue_id: new_entity.id)
original_entity.reload original_entity.reset
end end
end end
end end
......
...@@ -18,7 +18,7 @@ module Epics ...@@ -18,7 +18,7 @@ module Epics
if have_epic_dates_changed?(epic) if have_epic_dates_changed?(epic)
epic.update_start_and_due_dates epic.update_start_and_due_dates
epic.reload epic.reset
end end
epic epic
......
...@@ -48,7 +48,7 @@ module Gitlab ...@@ -48,7 +48,7 @@ module Gitlab
# No caching of the enabled! If we cache it and an admin disables # No caching of the enabled! If we cache it and an admin disables
# this node, an active Geo::RepositorySyncWorker would keep going for up # this node, an active Geo::RepositorySyncWorker would keep going for up
# to max run time after the node was disabled. # to max run time after the node was disabled.
Gitlab::Geo.current_node.reload.enabled? Gitlab::Geo.current_node.reset.enabled?
end end
def self.geo_database_configured? def self.geo_database_configured?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment