Commit e44df30e authored by Michael Kozono's avatar Michael Kozono

Keep the minimum cursor last event

parent 6e3e3bff
...@@ -41,7 +41,7 @@ module Geo ...@@ -41,7 +41,7 @@ module Geo
def prune!(relation, limit) def prune!(relation, limit)
unless delete_all? unless delete_all?
relation = relation.up_to_event(event_log_min_id) relation = relation.up_to_event(event_log_min_id - 1)
end end
deleted = relation.delete_with_limit(limit) 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 ...@@ -61,12 +61,12 @@ describe Geo::PruneEventLogService do
context 'with event_log_min_id' do context 'with event_log_min_id' do
let(:min_id) { events[1].id } let(:min_id) { events[1].id }
it 'prunes events up to the min id' do it 'prunes events up to, but not including, the min id' do
expect { service.execute }.to change { Geo::EventLog.count }.by(-2) expect { service.execute }.to change { Geo::EventLog.count }.by(-1)
end end
it 'prunes all associated events' do 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
end end
......
...@@ -44,7 +44,7 @@ describe Geo::PruneEventLogWorker, :geo do ...@@ -44,7 +44,7 @@ describe Geo::PruneEventLogWorker, :geo do
create_list(:geo_event_log, 2, :updated_event) 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) 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 end
it 'delegates pruning to Geo::PruneEventLogService' do it 'delegates pruning to Geo::PruneEventLogService' do
...@@ -118,7 +118,7 @@ describe Geo::PruneEventLogWorker, :geo 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) 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(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 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