summaryrefslogtreecommitdiff
path: root/spec/models/event_spec.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-10-04 17:22:58 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2016-10-04 19:41:37 +0200
commitc9bcfc631a79db97203d51d7c221a7549ba65adf (patch)
tree01a8be8de90c498e916bc9f6d8c2bc7478e89226 /spec/models/event_spec.rb
parent7887a3dafb6902cc39c831e307c48faf49f80b51 (diff)
downloadgitlab-ce-c9bcfc631a79db97203d51d7c221a7549ba65adf.tar.gz
Remove lease from Event#reset_project_activityremove-reset-project-activity-lease
Per GitLab.com's performance metrics this method could take up to 5 seconds of wall time to complete, while only taking 1-2 milliseconds of CPU time. Removing the Redis lease in favour of conditional updates allows us to work around this. A slight drawback is that this allows for multiple threads/processes to try and update the same row. However, only a single thread/process will ever win since the UPDATE query uses a WHERE condition to only update rows that were not updated in the last hour. Fixes gitlab-org/gitlab-ce#22473
Diffstat (limited to 'spec/models/event_spec.rb')
-rw-r--r--spec/models/event_spec.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 8600eb4d2c4..af5002487cc 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -173,13 +173,11 @@ describe Event, models: true do
it 'updates the project' do
project.update(last_activity_at: 1.year.ago)
- expect_any_instance_of(Gitlab::ExclusiveLease).
- to receive(:try_obtain).and_return(true)
+ create_event(project, project.owner)
- expect(project).to receive(:update_column).
- with(:last_activity_at, a_kind_of(Time))
+ project.reload
- create_event(project, project.owner)
+ project.last_activity_at <= 1.minute.ago
end
end
end