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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9550c353f31dc1d34a15993bdfbf279d87979ebb625ae776fb6727d7dc9e897e
4
- data.tar.gz: 379f8faac5d3369551b4012a00f522d7871a4001776120c4e02535b70bdef8a3
3
+ metadata.gz: 5ab1bd6816331fee7e233542126f85236688fc647050bfc18a1b635e78cd34e5
4
+ data.tar.gz: 8b5a8e483f8052ed8a01b77a5a610d06bb9b4f3b59b253982d96c353a24fa113
5
5
  SHA512:
6
- metadata.gz: 4dbb7a9366256f16a0fd7fbf22938d94c7754cdd3d9189d3d7d94e0d8deda59859ec4822f1e3c1d05cc7a2a67c8501a79c83d7b0b69f91fd106d9b24b4f35b06
7
- data.tar.gz: 637e09a985feeef6144e5b172a04c8ceee5980eed3b1b49f2597e33bbf26522c43244bc2778905ba400cf0de6485166258103e09aa7a765e261f8971b89b2c06
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 < ::ActiveRecord::Base
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 || Rails.version < '5.2'
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 || Rails.version < '5.2'
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
- sql = "SELECT pg_advisory_xact_lock(#{connection.quote_table_name('half_md5_as_bigint')}(#{connection.quote(values['strand'])})); #{sql}" if values["strand"]
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
 
@@ -395,13 +395,6 @@ class Job
395
395
  result
396
396
  end
397
397
 
398
- if Rails.version < "4.1"
399
- def changes_applied
400
- @previously_changed = changes
401
- @changed_attributes.clear
402
- end
403
- end
404
-
405
398
  def save!(*a)
406
399
  save(*a) || raise(RecordNotSaved)
407
400
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Delayed
4
- VERSION = "2.2.1"
4
+ VERSION = "2.3.1"
5
5
  end
data/lib/delayed_job.rb CHANGED
@@ -18,6 +18,7 @@ require 'rails'
18
18
  require 'active_support/core_ext/module/attribute_accessors'
19
19
  require 'active_record'
20
20
  require 'after_transaction_commit'
21
+ require 'debug_inspector'
21
22
 
22
23
  require 'delayed/core_ext/kernel'
23
24
 
@@ -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
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec :path=>"../../"
3
+ gemspec :path => "../../"
4
4
 
5
5
  gem "rails", "~> 5.2.0"
6
- gem 'sinatra', "2.0.0.beta2"
7
- gem 'sinatra-contrib', "2.0.0.beta2"
6
+ gem 'sinatra', "~> 2.0"
7
+ gem 'sinatra-contrib', "~> 2.0"
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec :path=>"../../"
3
+ gemspec :path => "../../"
4
4
 
5
5
  gem "rails", "~> 6.0.0"
6
- gem 'sinatra', "2.0.0.beta2"
7
- gem 'sinatra-contrib', "2.0.0.beta2"
6
+ gem 'sinatra', "~> 2.0"
7
+ gem 'sinatra-contrib', "~> 2.0"
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../../"
4
+
5
+ gem "rails", "~> 6.1.0"
6
+ gem 'sinatra', "~> 2.0"
7
+ gem 'sinatra-contrib', "~> 2.0"
@@ -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).starts_with?("Some % Name")
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 < '5.2'
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.2.1
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-02-19 00:00:00.000000000 Z
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: '4.2'
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: '4.2'
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: '4.2'
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: '4.2'
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: '4.2'
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: '4.2'
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: 0.0.3
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: 0.0.3
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: 1.6.1
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: 1.6.1
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.8.0
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.8.0
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.7.1
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.7.1
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.1.4
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
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path=>"../../"
4
-
5
- gem "rails", "~> 4.2.5"
6
- gem "after_transaction_commit", "<2"
7
- gem 'test_after_commit', '0.4.1'
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path=>"../../"
4
-
5
- gem "rails", "~> 5.0.0"
6
- gem 'sinatra', "2.0.0.beta2"
7
- gem 'sinatra-contrib', "2.0.0.beta2"
@@ -1,7 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path=>"../../"
4
-
5
- gem "rails", "~> 5.1.0"
6
- gem 'sinatra', "2.0.0.beta2"
7
- gem 'sinatra-contrib', "2.0.0.beta2"