diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /app/models/namespaces/traversal/linear.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'app/models/namespaces/traversal/linear.rb')
-rw-r--r-- | app/models/namespaces/traversal/linear.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb index 687fa6a5334..16a9c20dfdc 100644 --- a/app/models/namespaces/traversal/linear.rb +++ b/app/models/namespaces/traversal/linear.rb @@ -47,6 +47,8 @@ module Namespaces # This uses rails internal before_commit API to sync traversal_ids on namespace create, right before transaction is committed. # This helps reduce the time during which the root namespace record is locked to ensure updated traversal_ids are valid before_commit :sync_traversal_ids, on: [:create] + + define_model_callbacks :sync_traversal_ids end class_methods do @@ -208,10 +210,12 @@ module Namespaces # # NOTE: self.traversal_ids will be stale. Reload for a fresh record. def sync_traversal_ids - # Clear any previously memoized root_ancestor as our ancestors have changed. - clear_memoization(:root_ancestor) + run_callbacks :sync_traversal_ids do + # Clear any previously memoized root_ancestor as our ancestors have changed. + clear_memoization(:root_ancestor) - Namespace::TraversalHierarchy.for_namespace(self).sync_traversal_ids! + Namespace::TraversalHierarchy.for_namespace(self).sync_traversal_ids! + end end # Lock the root of the hierarchy we just left, and lock the root of the hierarchy |