Skip to content

Commit e4b420f

Browse files
committed
fix order for event/log pruning jobs
1 parent 4b560cb commit e4b420f

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

app/workers/prune_event_logs_worker.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def perform(ts = Time.current.iso8601)
5757
accounts.unordered.find_each do |account|
5858
account_id = account.id
5959
event_logs = account.event_logs.where(created_date: ...cutoff_date)
60+
.reorder(created_date: :asc)
6061
plan = account.plan
6162

6263
total = event_logs.count
@@ -75,7 +76,7 @@ def perform(ts = Time.current.iso8601)
7576
end
7677

7778
count = event_logs.statement_timeout(STATEMENT_TIMEOUT) do
78-
prune = account.event_logs.where(id: event_logs.limit(BATCH_SIZE).reorder(nil).ids)
79+
prune = account.event_logs.where(id: event_logs.limit(BATCH_SIZE).ids)
7980

8081
# for ent accounts, we keep the event backlog for the retention period except dup high-volume events.
8182
# for std accounts, we prune everything in the event backlog.

app/workers/prune_metrics_worker.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def perform(ts = Time.current.iso8601)
2525
accounts.unordered.find_each do |account|
2626
account_id = account.id
2727
metrics = account.metrics.where(created_date: ...cutoff_date)
28+
.reorder(created_date: :asc)
2829

2930
total = metrics.count
3031
sum = 0
@@ -42,7 +43,7 @@ def perform(ts = Time.current.iso8601)
4243
end
4344

4445
count = metrics.statement_timeout(STATEMENT_TIMEOUT) do
45-
account.metrics.where(id: metrics.limit(BATCH_SIZE).reorder(nil).ids)
46+
account.metrics.where(id: metrics.limit(BATCH_SIZE).ids)
4647
.delete_all
4748
end
4849

app/workers/prune_release_download_links_worker.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def perform
1818
accounts.unordered.find_each do |account|
1919
account_id = account.id
2020
downloads = account.release_download_links.where('created_at < ?', cutoff_time)
21+
.reorder(created_at: :asc)
2122

2223
total = downloads.count
2324
sum = 0

app/workers/prune_release_upgrade_links_worker.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def perform
1818
accounts.unordered.find_each do |account|
1919
account_id = account.id
2020
upgrades = account.release_upgrade_links.where('created_at < ?', cutoff_time)
21+
.reorder(created_at: :asc)
2122

2223
total = upgrades.count
2324
sum = 0

app/workers/prune_request_logs_worker.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def perform(ts = Time.current.iso8601)
2525
accounts.unordered.find_each do |account|
2626
account_id = account.id
2727
request_logs = account.request_logs.where(created_date: ...cutoff_date)
28+
.reorder(created_date: :asc)
2829
plan = account.plan
2930

3031
total = request_logs.count
@@ -43,7 +44,7 @@ def perform(ts = Time.current.iso8601)
4344
end
4445

4546
count = request_logs.statement_timeout(STATEMENT_TIMEOUT) do
46-
prune = account.request_logs.where(id: request_logs.limit(BATCH_SIZE).reorder(nil).ids)
47+
prune = account.request_logs.where(id: request_logs.limit(BATCH_SIZE).ids)
4748

4849
# apply the account's log retention policy if there is one
4950
if plan.ent? && plan.request_log_retention_duration?

0 commit comments

Comments
 (0)