Commit dc220a3d authored by Ash McKenzie's avatar Ash McKenzie

Geo: Add more debug logging in log_cursor

parent c57622a2
...@@ -16,11 +16,13 @@ module Gitlab ...@@ -16,11 +16,13 @@ module Gitlab
end end
def run! def run!
logger.debug('#run!: start')
trap_signals trap_signals
until exit? until exit?
# Prevent the node from processing events unless it's a secondary # Prevent the node from processing events unless it's a secondary
unless Geo.secondary? unless Geo.secondary?
logger.debug("#run!: not a secondary, sleeping for #{SECONDARY_CHECK_INTERVAL} secs")
sleep_break(SECONDARY_CHECK_INTERVAL) sleep_break(SECONDARY_CHECK_INTERVAL)
next next
end end
...@@ -31,6 +33,8 @@ module Gitlab ...@@ -31,6 +33,8 @@ module Gitlab
# When no new event is found sleep for a few moments # When no new event is found sleep for a few moments
arbitrary_sleep(lease[:ttl]) arbitrary_sleep(lease[:ttl])
end end
logger.debug('#run!: finish')
end end
def run_once! def run_once!
...@@ -54,7 +58,7 @@ module Gitlab ...@@ -54,7 +58,7 @@ module Gitlab
end end
def handle_events(batch, previous_batch_last_id) def handle_events(batch, previous_batch_last_id)
logger.info("Handling events", first_id: batch.first.id, last_id: batch.last.id) logger.info("#handle_events:", first_id: batch.first.id, last_id: batch.last.id)
gap_tracking.previous_id = previous_batch_last_id gap_tracking.previous_id = previous_batch_last_id
...@@ -71,7 +75,7 @@ module Gitlab ...@@ -71,7 +75,7 @@ module Gitlab
# If a project is deleted, the event log and its associated event data # If a project is deleted, the event log and its associated event data
# could be purged from the log. We ignore this and move along. # could be purged from the log. We ignore this and move along.
unless event unless event
logger.warn("Unknown event", event_log_id: event_log.id) logger.warn("#handle_single_event: unknown event", event_log_id: event_log.id)
return return
end end
...@@ -97,13 +101,13 @@ module Gitlab ...@@ -97,13 +101,13 @@ module Gitlab
end end
def trap_signals def trap_signals
trap(:TERM) { quit! } trap(:TERM) { quit!(:term) }
trap(:INT) { quit! } trap(:INT) { quit!(:int) }
end end
# Safe shutdown # Safe shutdown
def quit! def quit!(signal)
$stdout.puts 'Exiting...' warn("Signal #{signal} received, Exiting...")
@exit = true @exit = true
end end
...@@ -140,7 +144,11 @@ module Gitlab ...@@ -140,7 +144,11 @@ module Gitlab
end end
def log_level def log_level
options[:debug] ? :debug : Rails.logger.level # rubocop:disable Gitlab/RailsLogger debug_logging? ? :debug : Rails.logger.level # rubocop:disable Gitlab/RailsLogger
end
def debug_logging?
options[:debug]
end end
def event_data(event_log) def event_data(event_log)
......
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