Commit 6f9e1118 authored by Jennie Louie's avatar Jennie Louie Committed by Douglas Barbosa Alexandre

Add break clause to log cursor event processing

parent c58c97cc
......@@ -48,7 +48,11 @@ module Gitlab
# Wrap this with the connection to make it possible to reconnect if
# PGbouncer dies: https://github.com/rails/rails/issues/29189
ActiveRecord::Base.connection_pool.with_connection do
LogCursor::EventLogs.new.fetch_in_batches { |batch, last_id| handle_events(batch, last_id) }
LogCursor::EventLogs.new.fetch_in_batches do |batch, last_id|
break if exit?
handle_events(batch, last_id)
end
end
end
......
......@@ -136,6 +136,15 @@ describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state do
daemon.find_and_handle_events!
end
it 'exits when told to stop' do
allow_any_instance_of(::Gitlab::Geo::LogCursor::EventLogs).to receive(:fetch_in_batches)
allow(daemon).to receive(:exit?).and_return(true)
expect(daemon).not_to receive(:handle_events)
daemon.find_and_handle_events!
end
end
context 'when node has namespace restrictions' do
......
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