Skip to content

Commit 2ea5f07

Browse files
authored
[fix] Thread callback ordering (#53)
/no-platform /domain @argvniyx-enroute @mavenraven PR #42 inadvertently flipped the order of `:thread` and `:perform`, and also pushed `:thread` far enough in that cleanup steps would happen after the `with_connection`'s`end` block in the connection plugin. This introduces the possibility of thread safety issues, or connections being held longer than intended (exhausting the connection pool / connection limits).
1 parent b5abf39 commit 2ea5f07

7 files changed

Lines changed: 141 additions & 115 deletions

File tree

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ Rails/EnvironmentVariableAccess:
2020

2121
RSpec/IndexedLet:
2222
Enabled: false
23+
24+
Capybara/RSpec/PredicateMatcher:
25+
Enabled: false

.rubocop_todo.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-auto-gen-timestamp`
3-
# using RuboCop version 1.71.1.
3+
# using RuboCop version 1.75.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 13
9+
# Offense count: 14
1010
Betterment/ActiveJobPerformable:
1111
Exclude:
1212
- 'lib/delayed/performable_mailer.rb'
1313
- 'lib/delayed/performable_method.rb'
14+
- 'lib/delayed/worker.rb'
1415
- 'spec/autoloaded/clazz.rb'
1516
- 'spec/autoloaded/instance_clazz.rb'
1617
- 'spec/autoloaded/instance_struct.rb'
@@ -29,6 +30,12 @@ Betterment/DirectDelayedEnqueue:
2930
- 'spec/performable_method_spec.rb'
3031
- 'spec/worker_spec.rb'
3132

33+
# Offense count: 19
34+
Betterment/EnvironmentConfiguration:
35+
Exclude:
36+
- 'Rakefile'
37+
- 'lib/delayed/tasks.rb'
38+
3239
# Offense count: 1
3340
# This cop supports safe autocorrection (--autocorrect).
3441
# Configuration parameters: Severity, Include.

Gemfile.lock

Lines changed: 115 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,90 @@
11
PATH
22
remote: .
33
specs:
4-
delayed (0.7.1)
4+
delayed (0.7.2)
55
activerecord (>= 5.2)
66
concurrent-ruby
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
actionmailer (7.1.5.1)
12-
actionpack (= 7.1.5.1)
13-
actionview (= 7.1.5.1)
14-
activejob (= 7.1.5.1)
15-
activesupport (= 7.1.5.1)
16-
mail (~> 2.5, >= 2.5.4)
17-
net-imap
18-
net-pop
19-
net-smtp
11+
actionmailer (8.0.2)
12+
actionpack (= 8.0.2)
13+
actionview (= 8.0.2)
14+
activejob (= 8.0.2)
15+
activesupport (= 8.0.2)
16+
mail (>= 2.8.0)
2017
rails-dom-testing (~> 2.2)
21-
actionpack (7.1.5.1)
22-
actionview (= 7.1.5.1)
23-
activesupport (= 7.1.5.1)
18+
actionpack (8.0.2)
19+
actionview (= 8.0.2)
20+
activesupport (= 8.0.2)
2421
nokogiri (>= 1.8.5)
25-
racc
2622
rack (>= 2.2.4)
2723
rack-session (>= 1.0.1)
2824
rack-test (>= 0.6.3)
2925
rails-dom-testing (~> 2.2)
3026
rails-html-sanitizer (~> 1.6)
31-
actionview (7.1.5.1)
32-
activesupport (= 7.1.5.1)
27+
useragent (~> 0.16)
28+
actionview (8.0.2)
29+
activesupport (= 8.0.2)
3330
builder (~> 3.1)
3431
erubi (~> 1.11)
3532
rails-dom-testing (~> 2.2)
3633
rails-html-sanitizer (~> 1.6)
37-
activejob (7.1.5.1)
38-
activesupport (= 7.1.5.1)
34+
activejob (8.0.2)
35+
activesupport (= 8.0.2)
3936
globalid (>= 0.3.6)
40-
activemodel (7.1.5.1)
41-
activesupport (= 7.1.5.1)
42-
activerecord (7.1.5.1)
43-
activemodel (= 7.1.5.1)
44-
activesupport (= 7.1.5.1)
37+
activemodel (8.0.2)
38+
activesupport (= 8.0.2)
39+
activerecord (8.0.2)
40+
activemodel (= 8.0.2)
41+
activesupport (= 8.0.2)
4542
timeout (>= 0.4.0)
46-
activesupport (7.1.5.1)
43+
activesupport (8.0.2)
4744
base64
4845
benchmark (>= 0.3)
4946
bigdecimal
50-
concurrent-ruby (~> 1.0, >= 1.0.2)
47+
concurrent-ruby (~> 1.0, >= 1.3.1)
5148
connection_pool (>= 2.2.5)
5249
drb
5350
i18n (>= 1.6, < 2)
5451
logger (>= 1.4.2)
5552
minitest (>= 5.1)
56-
mutex_m
5753
securerandom (>= 0.3)
58-
tzinfo (~> 2.0)
54+
tzinfo (~> 2.0, >= 2.0.5)
55+
uri (>= 0.13.1)
5956
appraisal (2.5.0)
6057
bundler
6158
rake
6259
thor (>= 0.14.0)
63-
ast (2.4.2)
60+
ast (2.4.3)
6461
base64 (0.2.0)
6562
benchmark (0.4.0)
66-
betterlint (1.18.0)
63+
betterlint (1.19.0)
6764
rubocop (~> 1.71)
6865
rubocop-graphql (~> 1.5)
6966
rubocop-performance (~> 1.23)
7067
rubocop-rails (~> 2.29)
7168
rubocop-rake (~> 0.6)
7269
rubocop-rspec (~> 2.29)
7370
bigdecimal (3.1.9)
74-
builder (3.2.4)
75-
concurrent-ruby (1.2.3)
76-
connection_pool (2.4.1)
71+
builder (3.3.0)
72+
concurrent-ruby (1.3.5)
73+
connection_pool (2.5.0)
7774
crass (1.0.6)
78-
date (3.3.4)
79-
diff-lcs (1.5.1)
75+
date (3.4.1)
76+
diff-lcs (1.6.1)
8077
drb (2.2.1)
81-
erubi (1.12.0)
78+
erubi (1.13.1)
8279
globalid (1.2.1)
8380
activesupport (>= 6.1)
84-
i18n (1.14.6)
81+
i18n (1.14.7)
8582
concurrent-ruby (~> 1.0)
86-
json (2.7.2)
87-
language_server-protocol (3.17.0.3)
88-
logger (1.6.5)
89-
loofah (2.22.0)
83+
json (2.10.2)
84+
language_server-protocol (3.17.0.4)
85+
lint_roller (1.1.0)
86+
logger (1.7.0)
87+
loofah (2.24.0)
9088
crass (~> 1.0.2)
9189
nokogiri (>= 1.12.0)
9290
mail (2.8.1)
@@ -95,40 +93,45 @@ GEM
9593
net-pop
9694
net-smtp
9795
mini_mime (1.1.5)
98-
minitest (5.22.3)
99-
mutex_m (0.2.0)
96+
minitest (5.25.5)
10097
mysql2 (0.5.6)
101-
net-imap (0.4.18)
98+
net-imap (0.5.6)
10299
date
103100
net-protocol
104101
net-pop (0.1.2)
105102
net-protocol
106103
net-protocol (0.2.2)
107104
timeout
108-
net-smtp (0.5.0)
105+
net-smtp (0.5.1)
109106
net-protocol
110-
nokogiri (1.16.8-aarch64-linux)
107+
nokogiri (1.18.6-aarch64-linux-gnu)
108+
racc (~> 1.4)
109+
nokogiri (1.18.6-aarch64-linux-musl)
111110
racc (~> 1.4)
112-
nokogiri (1.16.8-arm-linux)
111+
nokogiri (1.18.6-arm-linux-gnu)
113112
racc (~> 1.4)
114-
nokogiri (1.16.8-arm64-darwin)
113+
nokogiri (1.18.6-arm-linux-musl)
115114
racc (~> 1.4)
116-
nokogiri (1.16.8-x86-linux)
115+
nokogiri (1.18.6-arm64-darwin)
117116
racc (~> 1.4)
118-
nokogiri (1.16.8-x86_64-darwin)
117+
nokogiri (1.18.6-x86_64-darwin)
119118
racc (~> 1.4)
120-
nokogiri (1.16.8-x86_64-linux)
119+
nokogiri (1.18.6-x86_64-linux-gnu)
121120
racc (~> 1.4)
122-
parallel (1.24.0)
123-
parser (3.3.7.0)
121+
nokogiri (1.18.6-x86_64-linux-musl)
122+
racc (~> 1.4)
123+
parallel (1.26.3)
124+
parser (3.3.7.3)
124125
ast (~> 2.4.1)
125126
racc
126-
pg (1.5.6)
127+
pg (1.5.9)
128+
prism (1.4.0)
127129
racc (1.8.1)
128-
rack (3.0.11)
129-
rack-session (2.0.0)
130+
rack (3.1.12)
131+
rack-session (2.1.0)
132+
base64 (>= 0.1.0)
130133
rack (>= 3.0.0)
131-
rack-test (2.1.0)
134+
rack-test (2.2.0)
132135
rack (>= 1.3)
133136
rails-dom-testing (2.2.0)
134137
activesupport (>= 5.0.0)
@@ -144,73 +147,89 @@ GEM
144147
rspec-core (~> 3.13.0)
145148
rspec-expectations (~> 3.13.0)
146149
rspec-mocks (~> 3.13.0)
147-
rspec-core (3.13.0)
150+
rspec-core (3.13.3)
148151
rspec-support (~> 3.13.0)
149-
rspec-expectations (3.13.0)
152+
rspec-expectations (3.13.3)
150153
diff-lcs (>= 1.2.0, < 2.0)
151154
rspec-support (~> 3.13.0)
152-
rspec-mocks (3.13.0)
155+
rspec-mocks (3.13.2)
153156
diff-lcs (>= 1.2.0, < 2.0)
154157
rspec-support (~> 3.13.0)
155-
rspec-support (3.13.1)
156-
rubocop (1.71.1)
158+
rspec-support (3.13.2)
159+
rubocop (1.75.1)
157160
json (~> 2.3)
158-
language_server-protocol (>= 3.17.0)
161+
language_server-protocol (~> 3.17.0.2)
162+
lint_roller (~> 1.1.0)
159163
parallel (~> 1.10)
160164
parser (>= 3.3.0.2)
161165
rainbow (>= 2.2.2, < 4.0)
162166
regexp_parser (>= 2.9.3, < 3.0)
163-
rubocop-ast (>= 1.38.0, < 2.0)
167+
rubocop-ast (>= 1.43.0, < 2.0)
164168
ruby-progressbar (~> 1.7)
165169
unicode-display_width (>= 2.4.0, < 4.0)
166-
rubocop-ast (1.38.0)
167-
parser (>= 3.3.1.0)
168-
rubocop-capybara (2.20.0)
169-
rubocop (~> 1.41)
170-
rubocop-factory_bot (2.25.1)
171-
rubocop (~> 1.41)
172-
rubocop-graphql (1.5.4)
173-
rubocop (>= 1.50, < 2)
174-
rubocop-performance (1.23.1)
175-
rubocop (>= 1.48.1, < 2.0)
176-
rubocop-ast (>= 1.31.1, < 2.0)
177-
rubocop-rails (2.29.1)
170+
rubocop-ast (1.43.0)
171+
parser (>= 3.3.7.2)
172+
prism (~> 1.4)
173+
rubocop-capybara (2.22.1)
174+
lint_roller (~> 1.1)
175+
rubocop (~> 1.72, >= 1.72.1)
176+
rubocop-factory_bot (2.27.1)
177+
lint_roller (~> 1.1)
178+
rubocop (~> 1.72, >= 1.72.1)
179+
rubocop-graphql (1.5.5)
180+
lint_roller (~> 1.1)
181+
rubocop (>= 1.72.1, < 2)
182+
rubocop-performance (1.24.0)
183+
lint_roller (~> 1.1)
184+
rubocop (>= 1.72.1, < 2.0)
185+
rubocop-ast (>= 1.38.0, < 2.0)
186+
rubocop-rails (2.30.3)
178187
activesupport (>= 4.2.0)
188+
lint_roller (~> 1.1)
179189
rack (>= 1.1)
180-
rubocop (>= 1.52.0, < 2.0)
181-
rubocop-ast (>= 1.31.1, < 2.0)
182-
rubocop-rake (0.6.0)
183-
rubocop (~> 1.0)
190+
rubocop (>= 1.72.1, < 2.0)
191+
rubocop-ast (>= 1.38.0, < 2.0)
192+
rubocop-rake (0.7.1)
193+
lint_roller (~> 1.1)
194+
rubocop (>= 1.72.1)
184195
rubocop-rspec (2.31.0)
185196
rubocop (~> 1.40)
186197
rubocop-capybara (~> 2.17)
187198
rubocop-factory_bot (~> 2.22)
188199
rubocop-rspec_rails (~> 2.28)
189-
rubocop-rspec_rails (2.28.2)
190-
rubocop (~> 1.40)
200+
rubocop-rspec_rails (2.29.1)
201+
rubocop (~> 1.61)
191202
ruby-progressbar (1.13.0)
192203
securerandom (0.4.1)
193-
sqlite3 (2.5.0-aarch64-linux-gnu)
194-
sqlite3 (2.5.0-arm-linux-gnu)
195-
sqlite3 (2.5.0-arm64-darwin)
196-
sqlite3 (2.5.0-x86-linux-gnu)
197-
sqlite3 (2.5.0-x86_64-darwin)
198-
sqlite3 (2.5.0-x86_64-linux-gnu)
199-
thor (1.3.1)
200-
timecop (0.9.8)
204+
sqlite3 (2.6.0-aarch64-linux-gnu)
205+
sqlite3 (2.6.0-aarch64-linux-musl)
206+
sqlite3 (2.6.0-arm-linux-gnu)
207+
sqlite3 (2.6.0-arm-linux-musl)
208+
sqlite3 (2.6.0-arm64-darwin)
209+
sqlite3 (2.6.0-x86_64-darwin)
210+
sqlite3 (2.6.0-x86_64-linux-gnu)
211+
sqlite3 (2.6.0-x86_64-linux-musl)
212+
thor (1.3.2)
213+
timecop (0.9.10)
201214
timeout (0.4.3)
202215
tzinfo (2.0.6)
203216
concurrent-ruby (~> 1.0)
204-
unicode-display_width (2.5.0)
205-
zeitwerk (2.6.13)
217+
unicode-display_width (3.1.4)
218+
unicode-emoji (~> 4.0, >= 4.0.4)
219+
unicode-emoji (4.0.4)
220+
uri (1.0.3)
221+
useragent (0.16.11)
222+
zeitwerk (2.7.2)
206223

207224
PLATFORMS
208-
aarch64-linux
209-
arm-linux
225+
aarch64-linux-gnu
226+
aarch64-linux-musl
227+
arm-linux-gnu
228+
arm-linux-musl
210229
arm64-darwin
211-
x86-linux
212230
x86_64-darwin
213-
x86_64-linux
231+
x86_64-linux-gnu
232+
x86_64-linux-musl
214233

215234
DEPENDENCIES
216235
actionmailer
@@ -228,4 +247,4 @@ DEPENDENCIES
228247
zeitwerk
229248

230249
BUNDLED WITH
231-
2.6.3
250+
2.6.6

delayed.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
1818
spec.require_paths = ['lib']
1919
spec.summary = 'a multi-threaded, SQL-driven ActiveJob backend used at Betterment to process millions of background jobs per day'
2020

21-
spec.version = '0.7.1'
21+
spec.version = '0.7.2'
2222
spec.metadata = {
2323
'changelog_uri' => 'https://github.com/betterment/delayed/blob/main/CHANGELOG.md',
2424
'bug_tracker_uri' => 'https://github.com/betterment/delayed/issues',

lib/delayed.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ module Delayed
4242
mattr_accessor(:default_log_level) { 'info'.freeze }
4343
mattr_accessor(:plugins) do
4444
[
45-
Delayed::Plugins::Instrumentation,
4645
Delayed::Plugins::Connection,
46+
Delayed::Plugins::Instrumentation,
4747
]
4848
end
4949

0 commit comments

Comments
 (0)