Commit 12c6bfc0 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-geo-log-skipped-events' into 'master'

Geo: Log to geo.log when the Log Cursor skips an event

See merge request gitlab-org/gitlab-ee!6470
parents 6bdf064d fbb90c10
---
title: 'Geo: Log to geo.log when the Log Cursor skips an event'
merge_request:
author:
type: other
...@@ -45,7 +45,10 @@ module Gitlab ...@@ -45,7 +45,10 @@ module Gitlab
def handle_events(batch) def handle_events(batch)
batch.each do |event_log| batch.each do |event_log|
next unless can_replay?(event_log) unless can_replay?(event_log)
logger.event_info(event_log.created_at, 'Skipped event', event_data(event_log))
next
end
begin begin
event = event_log.event event = event_log.event
...@@ -105,6 +108,15 @@ module Gitlab ...@@ -105,6 +108,15 @@ module Gitlab
def log_level def log_level
options[:debug] ? :debug : Rails.logger.level options[:debug] ? :debug : Rails.logger.level
end end
def event_data(event_log)
{
event_log_id: event_log.id,
event_id: event_log.event.id,
event_type: event_log.event.class.name,
project_id: event_log.project_id
}
end
end end
end end
end end
......
...@@ -115,6 +115,22 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared ...@@ -115,6 +115,22 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
daemon.run_once! daemon.run_once!
end end
it 'logs a message for skipped events' do
secondary.update!(selective_sync_type: 'namespaces', namespaces: [group_2])
expect(Gitlab::Geo::Logger).to receive(:info).with(hash_including(
:pid,
:cursor_delay_s,
message: 'Skipped event',
class: 'Gitlab::Geo::LogCursor::Daemon',
event_log_id: event_log.id,
event_id: repository_updated_event.id,
event_type: 'Geo::RepositoryUpdatedEvent',
project_id: project.id))
daemon.run_once!
end
it 'does not replay events for projects that do not belong to selected shards to replicate' do it 'does not replay events for projects that do not belong to selected shards to replicate' do
secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken']) secondary.update!(selective_sync_type: 'shards', selective_sync_shards: ['broken'])
......
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