Commit fbb90c10 authored by Stan Hu's avatar Stan Hu

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

This commit adds messages such as the following:

{
   "severity":"INFO",
   "time":"2018-07-11T20:43:04.505Z",
   "pid":53975,
   "class":"Gitlab::Geo::LogCursor::Daemon",
   "message":"Skipped event",
   "log_event_id":1,
   "event_id":1,
   "event_type":"Geo::RepositoryUpdatedEvent",
   "project_id":1,
   "cursor_delay_s":0.077
}

This will help diagnose whether the cursor is actually skipping events.
parent a997bc26
---
title: 'Geo: Log to geo.log when the Log Cursor skips an event'
merge_request:
author:
type: other
......@@ -45,7 +45,10 @@ module Gitlab
def handle_events(batch)
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
event = event_log.event
......@@ -105,6 +108,15 @@ module Gitlab
def log_level
options[:debug] ? :debug : Rails.logger.level
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
......
......@@ -115,6 +115,22 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
daemon.run_once!
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
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