Commit eb528805 authored by Mike Kozono's avatar Mike Kozono

Fix race condition with `created` event

Anyway, there is no point in creating a registry during
`checksum_succeeded` event since verification will not proceed for a
registry that is not yet synced.
parent 9939a5f9
...@@ -182,6 +182,7 @@ module Geo ...@@ -182,6 +182,7 @@ module Geo
# Called by Gitlab::Geo::Replicator#consume # Called by Gitlab::Geo::Replicator#consume
def consume_event_checksum_succeeded(**params) def consume_event_checksum_succeeded(**params)
return unless Gitlab::Geo.secondary? return unless Gitlab::Geo.secondary?
return unless registry.persisted?
registry.verification_pending! registry.verification_pending!
end end
......
...@@ -457,10 +457,15 @@ RSpec.shared_examples 'a verifiable replicator' do ...@@ -457,10 +457,15 @@ RSpec.shared_examples 'a verifiable replicator' do
end end
context 'on a Geo secondary' do context 'on a Geo secondary' do
before do
stub_secondary_node
end
context 'with a persisted registry' do
let(:registry) { replicator.registry } let(:registry) { replicator.registry }
before do before do
stub_secondary_node registry.save!
end end
context 'with a registry which is verified' do context 'with a registry which is verified' do
...@@ -487,6 +492,15 @@ RSpec.shared_examples 'a verifiable replicator' do ...@@ -487,6 +492,15 @@ RSpec.shared_examples 'a verifiable replicator' do
end end
end end
end end
context 'with an unpersisted registry' do
it 'does not persist the registry' do
replicator.consume_event_checksum_succeeded
expect(replicator.registry.persisted?).to be_falsey
end
end
end
end end
end end
......
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