summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-07-20 10:14:08 +0000
committerRémy Coutable <remy@rymai.me>2016-07-20 10:14:08 +0000
commit1ae2be239a9ce32024a6de061dd850c68fbdb5c2 (patch)
tree51e2717359134f996aa511b9bb79de4703f32e39
parentef2edcc10007d5d838acf278ed1e9e0c07cdc4fc (diff)
parenteb122e40a2ba8d1fe79d746deb4c7c803f8164a0 (diff)
downloadgitlab-ce-1ae2be239a9ce32024a6de061dd850c68fbdb5c2.tar.gz
Merge branch '20011-incosistent-branch-cache-state' into 'master'
Expire tags/branches repo cache before delete a repository ## What does this MR do? Explicitly expire tag and branch cache data before deleting a repository. Those keys don't depend on git data when they are expired ## Why was this MR needed? To solve an existing problem https://sentry.gitlap.com/gitlab/gitlabcom/issues/8756/ ## What are the relevant issue numbers? Closes #20011 ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - ~~[ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~ - ~~[ ] API support added~~ - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5356
-rw-r--r--app/models/repository.rb5
-rw-r--r--spec/models/repository_spec.rb48
2 files changed, 53 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 1a2ac90da51..511df2d67c6 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -392,6 +392,11 @@ class Repository
expire_cache if exists?
+ # expire cache that don't depend on repository data (when expiring)
+ expire_tags_cache
+ expire_tag_count_cache
+ expire_branches_cache
+ expire_branch_count_cache
expire_root_ref_cache
expire_emptiness_caches
expire_exists_cache
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 110df6bbd22..59c5732c075 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -749,6 +749,30 @@ describe Repository, models: true do
repository.before_delete
end
+ it 'flushes the tags cache' do
+ expect(repository).to receive(:expire_tags_cache)
+
+ repository.before_delete
+ end
+
+ it 'flushes the tag count cache' do
+ expect(repository).to receive(:expire_tag_count_cache)
+
+ repository.before_delete
+ end
+
+ it 'flushes the branches cache' do
+ expect(repository).to receive(:expire_branches_cache)
+
+ repository.before_delete
+ end
+
+ it 'flushes the branch count cache' do
+ expect(repository).to receive(:expire_branch_count_cache)
+
+ repository.before_delete
+ end
+
it 'flushes the root ref cache' do
expect(repository).to receive(:expire_root_ref_cache)
@@ -779,6 +803,30 @@ describe Repository, models: true do
repository.before_delete
end
+ it 'flushes the tags cache' do
+ expect(repository).to receive(:expire_tags_cache)
+
+ repository.before_delete
+ end
+
+ it 'flushes the tag count cache' do
+ expect(repository).to receive(:expire_tag_count_cache)
+
+ repository.before_delete
+ end
+
+ it 'flushes the branches cache' do
+ expect(repository).to receive(:expire_branches_cache)
+
+ repository.before_delete
+ end
+
+ it 'flushes the branch count cache' do
+ expect(repository).to receive(:expire_branch_count_cache)
+
+ repository.before_delete
+ end
+
it 'flushes the root ref cache' do
expect(repository).to receive(:expire_root_ref_cache)