From 825e617fe99099273898c7bccd53b72e62ddb0e3 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 19 Oct 2016 22:26:54 +0200 Subject: [PATCH] Run only one pipeline and project processing when scheduled multiple times --- CHANGELOG.md | 1 + Gemfile | 1 + Gemfile.lock | 4 ++++ app/workers/pipeline_process_worker.rb | 2 +- app/workers/pipeline_update_worker.rb | 2 +- app/workers/project_cache_worker.rb | 3 ++- 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4d317fd1db7..dffc9dc79ba3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Please view this file on the master branch, on stable branches it's out of date. - Change user & group landing page routing from /u/:username to /:username - Added documentation for .gitattributes files - Move Pipeline Metrics to separate worker + - Run only one pipeline and project processing when scheduled multiple times - AbstractReferenceFilter caches project_refs on RequestStore when active - Replaced the check sign to arrow in the show build view. !6501 - Add a /wip slash command to toggle the Work In Progress status of a merge request. !6259 (tbalthazar) diff --git a/Gemfile b/Gemfile index 05166b6a828b..ee83e50317e6 100644 --- a/Gemfile +++ b/Gemfile @@ -136,6 +136,7 @@ gem 'acts-as-taggable-on', '~> 4.0' # Background jobs gem 'sidekiq', '~> 4.2' gem 'sidekiq-cron', '~> 0.4.0' +gem 'sidekiq-unique-jobs' gem 'redis-namespace', '~> 1.5.2' # HTTP requests diff --git a/Gemfile.lock b/Gemfile.lock index a9892d1c1300..63c32155f8a5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -685,6 +685,9 @@ GEM redis-namespace (>= 1.5.2) rufus-scheduler (>= 2.0.24) sidekiq (>= 4.0.0) + sidekiq-unique-jobs (4.0.18) + sidekiq (>= 2.6) + thor simplecov (0.12.0) docile (~> 1.1.0) json (>= 1.8, < 3) @@ -961,6 +964,7 @@ DEPENDENCIES shoulda-matchers (~> 2.8.0) sidekiq (~> 4.2) sidekiq-cron (~> 0.4.0) + sidekiq-unique-jobs simplecov (= 0.12.0) slack-notifier (~> 1.2.0) spinach-rails (~> 0.2.1) diff --git a/app/workers/pipeline_process_worker.rb b/app/workers/pipeline_process_worker.rb index f44227d7086b..f659979e5a62 100644 --- a/app/workers/pipeline_process_worker.rb +++ b/app/workers/pipeline_process_worker.rb @@ -1,7 +1,7 @@ class PipelineProcessWorker include Sidekiq::Worker - sidekiq_options queue: :default + sidekiq_options queue: :default, unique: :until_executed def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id) diff --git a/app/workers/pipeline_update_worker.rb b/app/workers/pipeline_update_worker.rb index 44a7f24e4013..d61dd96958f4 100644 --- a/app/workers/pipeline_update_worker.rb +++ b/app/workers/pipeline_update_worker.rb @@ -1,7 +1,7 @@ class PipelineUpdateWorker include Sidekiq::Worker - sidekiq_options queue: :default + sidekiq_options queue: :default, unique: :until_executed def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id) diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb index ccefd0f71a0d..7396a18d66a6 100644 --- a/app/workers/project_cache_worker.rb +++ b/app/workers/project_cache_worker.rb @@ -1,7 +1,8 @@ class ProjectCacheWorker include Sidekiq::Worker - sidekiq_options queue: :default + sidekiq_options queue: :default, unique: :until_executed + def perform(project_id) project = Project.find(project_id) -- GitLab