summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 14:14:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 14:14:25 +0000
commit4177ade69aea16948ba097e67ed7ebe05f6e1993 (patch)
tree1105d823b0e1bf5e6f1fc377a5025434f6b46f75
parent9dc93a4519d9d5d7be48ff274127136236a3adb3 (diff)
downloadgitlab-ce-4177ade69aea16948ba097e67ed7ebe05f6e1993.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-ee
-rw-r--r--app/models/namespaces/traversal/linear.rb20
-rwxr-xr-x[-rw-r--r--]vendor/gitignore/C++.gitignore0
-rwxr-xr-x[-rw-r--r--]vendor/gitignore/Java.gitignore0
3 files changed, 19 insertions, 1 deletions
diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb
index dd9ca8d9bea..294ef83b9b4 100644
--- a/app/models/namespaces/traversal/linear.rb
+++ b/app/models/namespaces/traversal/linear.rb
@@ -86,7 +86,25 @@ module Namespaces
raise UnboundedSearch.new('Must bound search by a top') unless top
without_sti_condition
- .traversal_ids_contains("{#{top.id}}")
+ .traversal_ids_contains(latest_traversal_ids(top))
+ end
+
+ # traversal_ids are a cached value.
+ #
+ # The traversal_ids value in a loaded object can become stale when compared
+ # to the database value. For example, if you load a hierarchy and then move
+ # a group, any previously loaded descendant objects will have out of date
+ # traversal_ids.
+ #
+ # To solve this problem, we never depend on the object's traversal_ids
+ # value. We always query the database first with a sub-select for the
+ # latest traversal_ids.
+ #
+ # Note that ActiveRecord will cache query results. You can avoid this by
+ # using `Model.uncached { ... }`
+ def latest_traversal_ids(namespace = self)
+ without_sti_condition.where('id = (?)', namespace)
+ .select('traversal_ids as latest_traversal_ids')
end
end
end
diff --git a/vendor/gitignore/C++.gitignore b/vendor/gitignore/C++.gitignore
index 259148fa18f..259148fa18f 100644..100755
--- a/vendor/gitignore/C++.gitignore
+++ b/vendor/gitignore/C++.gitignore
diff --git a/vendor/gitignore/Java.gitignore b/vendor/gitignore/Java.gitignore
index a1c2a238a96..a1c2a238a96 100644..100755
--- a/vendor/gitignore/Java.gitignore
+++ b/vendor/gitignore/Java.gitignore