Skip to content

Commit

Permalink
Merge branch 'feat/DEX-2851/replica' into 'master'
Browse files Browse the repository at this point in the history
[DEX-2851] feat: user replica for deletion

Closes DEX-2851

See merge request nstmrt/rubygems/outbox!117
  • Loading branch information
Меркушин Михаил Сергеевич committed Feb 11, 2025
2 parents 05be2f4 + a033e1d commit e7459a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## [6.19.0] - 2025-02-11

### Added

- Querying minimum `created_at` for deletion now uses a replica database to reduce primary database load

## [6.18.0] - 2025-02-04

### Added
Expand Down
8 changes: 6 additions & 2 deletions app/jobs/sbmt/outbox/base_delete_stale_items_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def delete_items_in_batches_with_between(waterline, statuses)
table = item_class.arel_table
batch_size = item_class.config.deletion_batch_size
time_window = item_class.config.deletion_time_window
min_date = item_class.where(table[:status].in(statuses)).minimum(:created_at)
min_date = Outbox.database_switcher.use_slave do
item_class.where(table[:status].in(statuses)).minimum(:created_at)
end
deleted_count = nil

while min_date && min_date < waterline
Expand Down Expand Up @@ -174,7 +176,9 @@ def mysql_delete_in_batches(waterline_failed, waterline_delivered)
def delete_items_in_batches_with_between_mysql(waterline, statuses)
batch_size = item_class.config.deletion_batch_size
time_window = item_class.config.deletion_time_window
min_date = item_class.where(status: statuses).minimum(:created_at)
min_date = Outbox.database_switcher.use_slave do
item_class.where(status: statuses).minimum(:created_at)
end
deleted_count = nil

while min_date && min_date < waterline
Expand Down
2 changes: 1 addition & 1 deletion lib/sbmt/outbox/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Sbmt
module Outbox
VERSION = "6.18.0"
VERSION = "6.19.0"
end
end

0 comments on commit e7459a3

Please sign in to comment.