inst-jobs 2.2.1 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed/backend/active_record.rb +10 -16
- data/lib/delayed/backend/redis/job.rb +0 -7
- data/lib/delayed/version.rb +1 -1
- data/lib/delayed_job.rb +1 -0
- data/spec/active_record_job_spec.rb +15 -4
- data/spec/gemfiles/52.gemfile +3 -3
- data/spec/gemfiles/60.gemfile +3 -3
- data/spec/gemfiles/61.gemfile +7 -0
- data/spec/shared/worker.rb +1 -1
- data/spec/spec_helper.rb +1 -12
- metadata +35 -25
- data/spec/gemfiles/42.gemfile +0 -7
- data/spec/gemfiles/50.gemfile +0 -7
- data/spec/gemfiles/51.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ab1bd6816331fee7e233542126f85236688fc647050bfc18a1b635e78cd34e5
|
4
|
+
data.tar.gz: 8b5a8e483f8052ed8a01b77a5a610d06bb9b4f3b59b253982d96c353a24fa113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1affab489a4655084667dee40a487964da7c50780e7124b15ed18b7319bad1db6606f11bde3e109feef9d09ed94c2fd7d70b5c8f0da049c6f3411f5d9d4bf67
|
7
|
+
data.tar.gz: eae5d0a5db108e6f0ed92567a466a1663a411fdeac386b159eba906d26f05bea199ef495c020f43ae10d03d6bf6efdfa198e8b39f46caf8d0fb7e8f2a7192704
|
@@ -13,9 +13,13 @@ end
|
|
13
13
|
module Delayed
|
14
14
|
module Backend
|
15
15
|
module ActiveRecord
|
16
|
+
class AbstractJob < ::ActiveRecord::Base
|
17
|
+
self.abstract_class = true
|
18
|
+
end
|
19
|
+
|
16
20
|
# A job object that is persisted to the database.
|
17
21
|
# Contains the work object as a YAML field.
|
18
|
-
class Job <
|
22
|
+
class Job < AbstractJob
|
19
23
|
include Delayed::Backend::Base
|
20
24
|
self.table_name = :delayed_jobs
|
21
25
|
|
@@ -27,7 +31,7 @@ module Delayed
|
|
27
31
|
|
28
32
|
class << self
|
29
33
|
def create(attributes, &block)
|
30
|
-
return super if connection.prepared_statements
|
34
|
+
return super if connection.prepared_statements
|
31
35
|
|
32
36
|
# modified from ActiveRecord::Persistence.create and ActiveRecord::Persistence#_insert_record
|
33
37
|
job = new(attributes, &block)
|
@@ -37,7 +41,7 @@ module Delayed
|
|
37
41
|
|
38
42
|
def single_step_create
|
39
43
|
connection = self.class.connection
|
40
|
-
return save if connection.prepared_statements
|
44
|
+
return save if connection.prepared_statements
|
41
45
|
|
42
46
|
# a before_save callback that we're skipping
|
43
47
|
initialize_defaults
|
@@ -66,7 +70,8 @@ module Delayed
|
|
66
70
|
# > Multiple queries sent in a single PQexec call are processed in a single transaction,
|
67
71
|
# unless there are explicit BEGIN/COMMIT commands included in the query string to divide
|
68
72
|
# it into multiple transactions.
|
69
|
-
|
73
|
+
# but we don't need to lock when inserting into Delayed::Failed
|
74
|
+
sql = "SELECT pg_advisory_xact_lock(#{connection.quote_table_name('half_md5_as_bigint')}(#{connection.quote(values['strand'])})); #{sql}" if values["strand"] && self.class == Job
|
70
75
|
result = connection.execute(sql, "#{self} Create")
|
71
76
|
self.id = result.values.first.first
|
72
77
|
result.clear
|
@@ -98,7 +103,7 @@ module Delayed
|
|
98
103
|
# to raise the lock level
|
99
104
|
before_create :lock_strand_on_create
|
100
105
|
def lock_strand_on_create
|
101
|
-
if strand.present?
|
106
|
+
if strand.present? && self.class == Job
|
102
107
|
self.class.connection.execute("SELECT pg_advisory_xact_lock(#{self.class.connection.quote_table_name('half_md5_as_bigint')}(#{self.class.connection.quote(strand)}))")
|
103
108
|
end
|
104
109
|
end
|
@@ -513,17 +518,6 @@ module Delayed
|
|
513
518
|
class Failed < Job
|
514
519
|
include Delayed::Backend::Base
|
515
520
|
self.table_name = :failed_jobs
|
516
|
-
# Rails hasn't completely loaded yet, and setting the table name will cache some stuff
|
517
|
-
# so reset that cache so that it will load correctly after Rails is all loaded
|
518
|
-
# It's fixed in Rails 5 to not cache anything when you set the table_name
|
519
|
-
if Rails.version < '5' && Rails.version >= '4.2'
|
520
|
-
@arel_engine = nil
|
521
|
-
@arel_table = nil
|
522
|
-
end
|
523
|
-
end
|
524
|
-
if Rails.version < '5' && Rails.version >= '4.2'
|
525
|
-
@arel_engine = nil
|
526
|
-
@arel_table = nil
|
527
521
|
end
|
528
522
|
end
|
529
523
|
|
data/lib/delayed/version.rb
CHANGED
data/lib/delayed_job.rb
CHANGED
@@ -262,8 +262,6 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
|
|
262
262
|
|
263
263
|
context "non-transactional", non_transactional: true do
|
264
264
|
it "creates a stranded job in a single statement" do
|
265
|
-
skip "Requires Rails 5.2 or greater" unless Rails.version >= '5.2'
|
266
|
-
|
267
265
|
allow(Delayed::Job.connection).to receive(:prepared_statements).and_return(false)
|
268
266
|
allow(Delayed::Job.connection).to receive(:execute).with(be_include("pg_advisory_xact_lock"), anything).and_call_original.once
|
269
267
|
allow(Delayed::Job.connection).to receive(:insert).never
|
@@ -273,8 +271,6 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
|
|
273
271
|
end
|
274
272
|
|
275
273
|
it "creates a non-stranded job in a single statement" do
|
276
|
-
skip "Requires Rails 5.2 or greater" unless Rails.version >= '5.2'
|
277
|
-
|
278
274
|
allow(Delayed::Job.connection).to receive(:prepared_statements).and_return(false)
|
279
275
|
call_count = 0
|
280
276
|
allow(Delayed::Job.connection).to receive(:execute).and_wrap_original do |m, (arg1, arg2)|
|
@@ -286,5 +282,20 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
|
|
286
282
|
expect(call_count).to eq 1
|
287
283
|
expect(Delayed::Job.find(j.id)).to eq j
|
288
284
|
end
|
285
|
+
|
286
|
+
it "does not lock a stranded failed job creation" do
|
287
|
+
j = create_job(strand: "test1")
|
288
|
+
# query for metadata to ensure it's loaded before we start mucking with the connection
|
289
|
+
Delayed::Backend::ActiveRecord::Job::Failed.new
|
290
|
+
|
291
|
+
allow(Delayed::Job.connection).to receive(:prepared_statements).and_return(false)
|
292
|
+
allow(Delayed::Job.connection).to receive(:execute).and_wrap_original do |original, *args|
|
293
|
+
expect(args.first).not_to include("pg_advisory_xact_lock")
|
294
|
+
original.call(*args)
|
295
|
+
end
|
296
|
+
allow(Delayed::Job.connection).to receive(:insert).never
|
297
|
+
j.fail!
|
298
|
+
allow(Delayed::Job.connection).to receive(:execute).and_call_original
|
299
|
+
end
|
289
300
|
end
|
290
301
|
end
|
data/spec/gemfiles/52.gemfile
CHANGED
data/spec/gemfiles/60.gemfile
CHANGED
data/spec/shared/worker.rb
CHANGED
@@ -21,7 +21,7 @@ shared_examples_for 'Delayed::Worker' do
|
|
21
21
|
|
22
22
|
describe "running a job" do
|
23
23
|
it "should not fail when running a job with a % in the name" do
|
24
|
-
@job = "Some % Name here".delay(ignore_transaction: true).
|
24
|
+
@job = "Some % Name here".delay(ignore_transaction: true).start_with?("Some % Name")
|
25
25
|
@worker.perform(@job)
|
26
26
|
end
|
27
27
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,6 @@ require 'delayed/testing'
|
|
5
5
|
|
6
6
|
require 'database_cleaner'
|
7
7
|
require 'rack/test'
|
8
|
-
require 'test_after_commit' if ::Rails.version < '5'
|
9
8
|
require 'timecop'
|
10
9
|
require 'webmock/rspec'
|
11
10
|
|
@@ -63,18 +62,8 @@ connection_config = {
|
|
63
62
|
database: ENV['TEST_DB_DATABASE'],
|
64
63
|
}
|
65
64
|
|
66
|
-
if ::Rails.version < '5'
|
67
|
-
class ActiveRecord::Migration
|
68
|
-
class << self
|
69
|
-
def [](_version); self; end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
65
|
def migrate(file)
|
75
|
-
if ::Rails.version
|
76
|
-
ActiveRecord::Migrator.migrate(file)
|
77
|
-
elsif ::Rails.version >= '6'
|
66
|
+
if ::Rails.version >= '6'
|
78
67
|
ActiveRecord::MigrationContext.new(file, ActiveRecord::SchemaMigration).migrate
|
79
68
|
else
|
80
69
|
ActiveRecord::MigrationContext.new(file).migrate
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '5.2'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '5.2'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activesupport
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '5.2'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '5.2'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: after_transaction_commit
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,14 +65,14 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '5.2'
|
69
69
|
type: :runtime
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '5.2'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: redis
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,14 +121,14 @@ dependencies:
|
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: '1.0'
|
125
125
|
type: :runtime
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: '1.0'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: bump
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,16 +161,30 @@ dependencies:
|
|
161
161
|
name: database_cleaner
|
162
162
|
requirement: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: '2.0'
|
167
167
|
type: :development
|
168
168
|
prerelease: false
|
169
169
|
version_requirements: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- -
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2.0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: database_cleaner-active_record
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2.0'
|
181
|
+
type: :development
|
182
|
+
prerelease: false
|
183
|
+
version_requirements: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
187
|
+
version: '2.0'
|
174
188
|
- !ruby/object:Gem::Dependency
|
175
189
|
name: diplomat
|
176
190
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,14 +275,14 @@ dependencies:
|
|
261
275
|
requirements:
|
262
276
|
- - "~>"
|
263
277
|
- !ruby/object:Gem::Version
|
264
|
-
version: 3.
|
278
|
+
version: '3.10'
|
265
279
|
type: :development
|
266
280
|
prerelease: false
|
267
281
|
version_requirements: !ruby/object:Gem::Requirement
|
268
282
|
requirements:
|
269
283
|
- - "~>"
|
270
284
|
- !ruby/object:Gem::Version
|
271
|
-
version: 3.
|
285
|
+
version: '3.10'
|
272
286
|
- !ruby/object:Gem::Dependency
|
273
287
|
name: sinatra
|
274
288
|
requirement: !ruby/object:Gem::Requirement
|
@@ -303,14 +317,14 @@ dependencies:
|
|
303
317
|
requirements:
|
304
318
|
- - '='
|
305
319
|
- !ruby/object:Gem::Version
|
306
|
-
version: 0.
|
320
|
+
version: 0.9.4
|
307
321
|
type: :development
|
308
322
|
prerelease: false
|
309
323
|
version_requirements: !ruby/object:Gem::Requirement
|
310
324
|
requirements:
|
311
325
|
- - '='
|
312
326
|
- !ruby/object:Gem::Version
|
313
|
-
version: 0.
|
327
|
+
version: 0.9.4
|
314
328
|
- !ruby/object:Gem::Dependency
|
315
329
|
name: webmock
|
316
330
|
requirement: !ruby/object:Gem::Requirement
|
@@ -436,11 +450,9 @@ files:
|
|
436
450
|
- spec/delayed/worker/consul_health_check_spec.rb
|
437
451
|
- spec/delayed/worker/health_check_spec.rb
|
438
452
|
- spec/delayed/worker_spec.rb
|
439
|
-
- spec/gemfiles/42.gemfile
|
440
|
-
- spec/gemfiles/50.gemfile
|
441
|
-
- spec/gemfiles/51.gemfile
|
442
453
|
- spec/gemfiles/52.gemfile
|
443
454
|
- spec/gemfiles/60.gemfile
|
455
|
+
- spec/gemfiles/61.gemfile
|
444
456
|
- spec/migrate/20140924140513_add_story_table.rb
|
445
457
|
- spec/redis_job_spec.rb
|
446
458
|
- spec/sample_jobs.rb
|
@@ -470,7 +482,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
470
482
|
- !ruby/object:Gem::Version
|
471
483
|
version: '0'
|
472
484
|
requirements: []
|
473
|
-
rubygems_version: 3.
|
485
|
+
rubygems_version: 3.2.15
|
474
486
|
signing_key:
|
475
487
|
specification_version: 4
|
476
488
|
summary: Instructure-maintained fork of delayed_job
|
@@ -478,11 +490,9 @@ test_files:
|
|
478
490
|
- spec/sample_jobs.rb
|
479
491
|
- spec/spec_helper.rb
|
480
492
|
- spec/redis_job_spec.rb
|
493
|
+
- spec/gemfiles/61.gemfile
|
481
494
|
- spec/gemfiles/60.gemfile
|
482
|
-
- spec/gemfiles/42.gemfile
|
483
495
|
- spec/gemfiles/52.gemfile
|
484
|
-
- spec/gemfiles/50.gemfile
|
485
|
-
- spec/gemfiles/51.gemfile
|
486
496
|
- spec/shared_jobs_specs.rb
|
487
497
|
- spec/shared/performable_method.rb
|
488
498
|
- spec/shared/testing.rb
|
data/spec/gemfiles/42.gemfile
DELETED
data/spec/gemfiles/50.gemfile
DELETED