Commit 32563183 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'mk/keep-last-remaining-event' into 'master'

Geo: Keep the minimum cursor last event

See merge request gitlab-org/gitlab-ee!8832
parents db42a531 e44df30e
......@@ -41,7 +41,7 @@ module Geo
def prune!(relation, limit)
unless delete_all?
relation = relation.up_to_event(event_log_min_id)
relation = relation.up_to_event(event_log_min_id - 1)
end
deleted = relation.delete_with_limit(limit)
......
---
title: 'Geo: Keep the minimum cursor last event'
merge_request: 8832
author:
type: fixed
......@@ -61,12 +61,12 @@ describe Geo::PruneEventLogService do
context 'with event_log_min_id' do
let(:min_id) { events[1].id }
it 'prunes events up to the min id' do
expect { service.execute }.to change { Geo::EventLog.count }.by(-2)
it 'prunes events up to, but not including, the min id' do
expect { service.execute }.to change { Geo::EventLog.count }.by(-1)
end
it 'prunes all associated events' do
expect { service.execute }.to change { Geo::RepositoryUpdatedEvent.count }.by(-2)
expect { service.execute }.to change { Geo::RepositoryUpdatedEvent.count }.by(-1)
end
end
......
......@@ -44,7 +44,7 @@ describe Geo::PruneEventLogWorker, :geo do
create_list(:geo_event_log, 2, :updated_event)
create(:geo_node_status, :healthy, cursor_last_event_id: Geo::EventLog.last.id, geo_node_id: secondary.id)
expect { worker.perform }.to change { Geo::RepositoryUpdatedEvent.count }.by(-2)
expect { worker.perform }.to change { Geo::RepositoryUpdatedEvent.count }.by(-1)
end
it 'delegates pruning to Geo::PruneEventLogService' do
......@@ -118,7 +118,7 @@ describe Geo::PruneEventLogWorker, :geo do
create(:geo_node_status, :healthy, cursor_last_event_id: events.last.id, geo_node_id: secondary2.id)
expect(Geo::PruneEventLogService).to receive(:new).with(events[3].id).and_call_original
expect { worker.perform }.to change { Geo::EventLog.count }.by(-4)
expect { worker.perform }.to change { Geo::EventLog.count }.by(-3)
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