sbmt-outbox 6.12.0 → 6.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/jobs/sbmt/outbox/base_delete_stale_items_job.rb +32 -5
- data/config/initializers/yabeda.rb +10 -0
- data/lib/sbmt/outbox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47ab689de26112df54d99c701fad3c6f492096173de831fc134318afa91c6662
|
4
|
+
data.tar.gz: b11e20111becd1d58cfca72a98d62adeb1b7573c0c093081b086331d90cc7b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df07282a29bf4468399747b2443965c35bcbc8590bcb5b6613fdad8c255cad9296dfdf9662399617f15ce39cd589e6f022a4da3c8611ee9d712714a10d36fcf
|
7
|
+
data.tar.gz: 0f14e1ed6c00ed9fd2c4fd4e9ff225330b507f0a9fbef4c39a32e86eeb0a7bebbf194a2b4040f5b4e2813b8438f27bb78a9a024b16784397ff0fe712143b505f
|
@@ -116,12 +116,17 @@ module Sbmt
|
|
116
116
|
delete_statement = Arel::Nodes::DeleteStatement.new
|
117
117
|
delete_statement.relation = table
|
118
118
|
delete_statement.wheres = [table[:id].in(subquery)]
|
119
|
+
deleted_count = nil
|
119
120
|
|
120
121
|
loop do
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
track_deleted_latency do
|
123
|
+
deleted_count = item_class
|
124
|
+
.connection
|
125
|
+
.execute(delete_statement.to_sql)
|
126
|
+
.cmd_tuples
|
127
|
+
end
|
128
|
+
|
129
|
+
track_deleted_counter(deleted_count)
|
125
130
|
|
126
131
|
logger.log_info("Deleted #{deleted_count} #{box_type} items for #{box_name} items")
|
127
132
|
break if deleted_count == 0
|
@@ -158,8 +163,14 @@ module Sbmt
|
|
158
163
|
end
|
159
164
|
|
160
165
|
def delete_items_in_batches_mysql(query)
|
166
|
+
deleted_count = nil
|
167
|
+
|
161
168
|
loop do
|
162
|
-
|
169
|
+
track_deleted_latency do
|
170
|
+
deleted_count = query.limit(BATCH_SIZE).delete_all
|
171
|
+
end
|
172
|
+
|
173
|
+
track_deleted_counter(deleted_count)
|
163
174
|
|
164
175
|
logger.log_info("Deleted #{deleted_count} #{box_type} items for #{box_name} items")
|
165
176
|
break if deleted_count == 0
|
@@ -179,6 +190,22 @@ module Sbmt
|
|
179
190
|
:unknown
|
180
191
|
end
|
181
192
|
end
|
193
|
+
|
194
|
+
def track_deleted_counter(deleted_count)
|
195
|
+
::Yabeda
|
196
|
+
.outbox
|
197
|
+
.deleted_counter
|
198
|
+
.increment({box_type: box_type, box_name: box_name}, by: deleted_count)
|
199
|
+
end
|
200
|
+
|
201
|
+
def track_deleted_latency
|
202
|
+
::Yabeda
|
203
|
+
.outbox
|
204
|
+
.delete_latency
|
205
|
+
.measure({box_type: box_type, box_name: box_name}) do
|
206
|
+
yield
|
207
|
+
end
|
208
|
+
end
|
182
209
|
end
|
183
210
|
end
|
184
211
|
end
|
@@ -43,6 +43,16 @@ Yabeda.configure do
|
|
43
43
|
unit: :seconds,
|
44
44
|
buckets: [0.5, 1, 2.5, 5, 10, 15, 20, 30, 45, 60, 300].freeze,
|
45
45
|
comment: "A histogram outbox process latency"
|
46
|
+
|
47
|
+
histogram :delete_latency,
|
48
|
+
tags: %i[box_type box_name],
|
49
|
+
unit: :seconds,
|
50
|
+
buckets: [0.005, 0.01, 0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 20, 30].freeze,
|
51
|
+
comment: "A histogram for outbox/inbox deletion latency"
|
52
|
+
|
53
|
+
counter :deleted_counter,
|
54
|
+
tags: %i[box_type box_name],
|
55
|
+
comment: "A counter for the number of deleted outbox/inbox items"
|
46
56
|
end
|
47
57
|
|
48
58
|
group :box_worker do
|
data/lib/sbmt/outbox/version.rb
CHANGED