Commit 5f2c8df4 authored by Toon Claes's avatar Toon Claes

Handle gap events in batches, in case there are thousands

parent 4c8aac57
---
title: Geo log cursor gap tracking performance improvements
merge_request: 6754
author:
type: performance
......@@ -52,10 +52,10 @@ module Gitlab
gap_ids = redis.zrangebyscore(GEO_EVENT_LOG_GAPS, '-inf', grace_timestamp).map(&:to_i)
event_logs = ::Geo::EventLog.includes_events.where(id: gap_ids)
event_logs.each { |event_log| yield event_log }
redis.zrem(GEO_EVENT_LOG_GAPS, event_logs.map(&:id)) if event_logs.any?
::Geo::EventLog.where(id: gap_ids).each_batch do |batch|
batch.includes_events.each { |event_log| yield event_log }
redis.zrem(GEO_EVENT_LOG_GAPS, batch.map(&:id))
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