Commit 79c6a1a7 authored by Gabriel Mazetto's avatar Gabriel Mazetto Committed by Douglas Barbosa Alexandre

Resolve "Geo::RepositoryVerification::Secondary::ShardWorker lease key is not...

Resolve "Geo::RepositoryVerification::Secondary::ShardWorker lease key is not namespaced by shard name"
parent dde69913
...@@ -14,17 +14,17 @@ module Geo ...@@ -14,17 +14,17 @@ module Geo
super() super()
end end
# We need a custom key here since we are running one worker per shard
def lease_key
@lease_key ||= "#{self.class.name.underscore}:shard:#{shard_name}"
end
private private
def worker_metadata def worker_metadata
{ shard: shard_name } { shard: shard_name }
end end
# We need a custom key here since we are running one worker per shard
def lease_key
@lease_key ||= "#{self.class.name.underscore}:shard:#{shard_name}"
end
def max_capacity def max_capacity
current_node.verification_max_capacity current_node.verification_max_capacity
end end
......
...@@ -14,6 +14,10 @@ module Geo ...@@ -14,6 +14,10 @@ module Geo
super() super()
end end
def lease_key
@lease_key ||= "#{self.class.name.underscore}:shard:#{shard_name}"
end
private private
def worker_metadata def worker_metadata
......
---
title: 'Geo: repository shard verification job should have unique lease keys per shard
name'
merge_request: 7474
author:
type: fixed
...@@ -19,6 +19,14 @@ describe Geo::RepositoryVerification::Primary::ShardWorker, :postgresql, :clean_ ...@@ -19,6 +19,14 @@ describe Geo::RepositoryVerification::Primary::ShardWorker, :postgresql, :clean_
Gitlab::ShardHealthCache.update([shard_name]) Gitlab::ShardHealthCache.update([shard_name])
end end
context 'shard worker scheduler' do
it 'acquires lock namespacing it per shard name' do
subject.perform(shard_name)
expect(subject.lease_key).to include(shard_name)
end
end
it 'performs Geo::RepositoryVerification::Primary::SingleWorker for each project' do it 'performs Geo::RepositoryVerification::Primary::SingleWorker for each project' do
create_list(:project, 2) create_list(:project, 2)
......
...@@ -22,7 +22,15 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea ...@@ -22,7 +22,15 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
Gitlab::ShardHealthCache.update([shard_name]) Gitlab::ShardHealthCache.update([shard_name])
end end
it 'schedules job for each project' do context 'shard worker scheduler' do
it 'acquires lock namespacing it per shard name' do
subject.perform(shard_name)
expect(subject.lease_key).to include(shard_name)
end
end
it 'schedule a job for each project' do
other_project = create(:project) other_project = create(:project)
create(:repository_state, :repository_verified, project: project) create(:repository_state, :repository_verified, project: project)
create(:repository_state, :repository_verified, project: other_project) create(:repository_state, :repository_verified, project: other_project)
...@@ -34,7 +42,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea ...@@ -34,7 +42,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
subject.perform(shard_name) subject.perform(shard_name)
end end
it 'schedules job for projects missing repository verification' do it 'schedule jobs for projects missing repository verification' do
create(:repository_state, :repository_verified, :wiki_verified, project: project) create(:repository_state, :repository_verified, :wiki_verified, project: project)
missing_repository_verification = create(:geo_project_registry, :synced, :wiki_verified, project: project) missing_repository_verification = create(:geo_project_registry, :synced, :wiki_verified, project: project)
...@@ -43,7 +51,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea ...@@ -43,7 +51,7 @@ describe Geo::RepositoryVerification::Secondary::ShardWorker, :postgresql, :clea
subject.perform(shard_name) subject.perform(shard_name)
end end
it 'schedules job for projects missing wiki verification' do it 'schedule jobs for projects missing wiki verification' do
create(:repository_state, :repository_verified, :wiki_verified, project: project) create(:repository_state, :repository_verified, :wiki_verified, project: project)
missing_wiki_verification = create(:geo_project_registry, :synced, :repository_verified, project: project) missing_wiki_verification = create(:geo_project_registry, :synced, :repository_verified, project: project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment