delayed_job_active_record 4.1.7 → 4.1.10

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: 4b17b594310d702d4a5dddca0001c067751c5c70595405ab74cf5091951e8dbf
4
- data.tar.gz: 2ccf2889e6d629cd46850873c8b1038eba50554ba7b76d1151974b750e70f3c1
3
+ metadata.gz: 9116a5f78649ace5869c7b445d6f7737050854002a61256874572e1a53483193
4
+ data.tar.gz: b603d4277c480fb9b81b2ac2b6d016f34ad4a303317c7125d7d5bf88c27b280c
5
5
  SHA512:
6
- metadata.gz: d0c30a1d2e4b220a1a12e61cd8f6745e13093c275c8f323c565cf919e92d65c8b9fa6ba35ca06532f5db3316e2128012c53076099b6940de71d351d8b2c0f6b8
7
- data.tar.gz: e6c1f74236b4c93a981bafda8b311d71db3edc25e90856d8bb9d72e8c9fe61df7642c23e72f30eae40fc99eecefc2a5e3e1a11393d9c66e0114ab926ecdace4b
6
+ metadata.gz: da14da981c5d80de7b6e608cea6d17dc509545efff2ed07277d9ac5ea3b22cba426363643f43685f3806baf66b03eb328ccf60b146987c41cf8fe4d0e5ea8bed
7
+ data.tar.gz: 899ff2554da143c1c36aa547286c54ffcbbb3dfa887743006d8b4d1f8413aae08cc5335c2341223fdaaa02c3628150f0a6db0cd750816d3f6485ba01ac4e8430
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  **If you're viewing this at https://github.com/collectiveidea/delayed_job_active_record,
2
2
  you're reading the documentation for the master branch.
3
3
  [View documentation for the latest release
4
- (4.1.7).](https://github.com/collectiveidea/delayed_job_active_record/tree/v4.1.7)**
4
+ (4.1.10).](https://github.com/collectiveidea/delayed_job_active_record/tree/v4.1.10)**
5
5
 
6
6
  # DelayedJob ActiveRecord Backend
7
7
 
@@ -1,17 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Gem::Specification.new do |spec|
4
+ spec.name = "delayed_job_active_record"
5
+ spec.version = "4.1.10"
6
+ spec.summary = "ActiveRecord backend for DelayedJob"
7
+ spec.description = "ActiveRecord backend for Delayed::Job, originally authored by Tobias Lütke"
8
+
9
+ spec.licenses = "MIT"
10
+
11
+ spec.authors = ["David Genord II", "Brian Ryckbost", "Matt Griffin", "Erik Michaels-Ober"]
12
+ spec.email = ["david@collectiveidea.com", "bryckbost@gmail.com", "matt@griffinonline.org", "sferik@gmail.com"]
13
+ spec.homepage = "http://github.com/collectiveidea/delayed_job_active_record"
14
+
15
+ spec.files = %w[CONTRIBUTING.md LICENSE.md README.md delayed_job_active_record.gemspec] + Dir["lib/**/*.rb"]
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.metadata = { "rubygems_mfa_required" => "true" }
19
+
4
20
  spec.add_dependency "activerecord", [">= 3.0", "< 8.0"]
5
21
  spec.add_dependency "delayed_job", [">= 3.0", "< 5"]
6
- spec.authors = ["Brian Ryckbost", "Matt Griffin", "Erik Michaels-Ober"]
7
- spec.description = "ActiveRecord backend for Delayed::Job, originally authored by Tobias Lütke"
8
- spec.email = ["bryckbost@gmail.com", "matt@griffinonline.org", "sferik@gmail.com"]
9
- spec.files = %w[CONTRIBUTING.md LICENSE.md README.md delayed_job_active_record.gemspec] + Dir["lib/**/*.rb"]
10
- spec.homepage = "http://github.com/collectiveidea/delayed_job_active_record"
11
- spec.licenses = ["MIT"]
12
- spec.metadata = { "rubygems_mfa_required" => "true" }
13
- spec.name = "delayed_job_active_record"
14
- spec.require_paths = ["lib"]
15
- spec.summary = "ActiveRecord backend for DelayedJob"
16
- spec.version = "4.1.7"
17
22
  end
@@ -62,7 +62,11 @@ module Delayed
62
62
  end
63
63
 
64
64
  def self.before_fork
65
- ::ActiveRecord::Base.clear_all_connections!
65
+ if Gem::Version.new("7.1.0") <= Gem::Version.new(::ActiveRecord::VERSION::STRING)
66
+ ::ActiveRecord::Base.connection_handler.clear_all_connections!(:all)
67
+ else
68
+ ::ActiveRecord::Base.connection_handler.clear_all_connections!
69
+ end
66
70
  end
67
71
 
68
72
  def self.after_fork
@@ -101,7 +105,7 @@ module Delayed
101
105
  case connection.adapter_name
102
106
  when "PostgreSQL", "PostGIS"
103
107
  reserve_with_scope_using_optimized_postgres(ready_scope, worker, now)
104
- when "MySQL", "Mysql2"
108
+ when "MySQL", "Mysql2", "Trilogy"
105
109
  reserve_with_scope_using_optimized_mysql(ready_scope, worker, now)
106
110
  when "MSSQL", "Teradata"
107
111
  reserve_with_scope_using_optimized_mssql(ready_scope, worker, now)
@@ -129,11 +133,23 @@ module Delayed
129
133
  # Note: active_record would attempt to generate UPDATE...LIMIT like
130
134
  # SQL for Postgres if we use a .limit() filter, but it would not
131
135
  # use 'FOR UPDATE' and we would have many locking conflicts
136
+ subquery = ready_scope.limit(1).lock(true).select("id").to_sql
137
+
138
+ # On PostgreSQL >= 9.5 we leverage SKIP LOCK to avoid multiple workers blocking each other
139
+ # when attempting to get the next available job
140
+ # https://www.postgresql.org/docs/9.5/sql-select.html#SQL-FOR-UPDATE-SHARE
141
+ if connection.send(:postgresql_version) >= 9_05_00 # rubocop:disable Style/NumericLiterals
142
+ subquery += " SKIP LOCKED"
143
+ end
144
+
132
145
  quoted_name = connection.quote_table_name(table_name)
133
- subquery = ready_scope.limit(1).lock(true).select("id").to_sql
134
- sql = "UPDATE #{quoted_name} SET locked_at = ?, locked_by = ? WHERE id IN (#{subquery}) RETURNING *"
135
- reserved = find_by_sql([sql, now, worker.name])
136
- reserved[0]
146
+ find_by_sql(
147
+ [
148
+ "UPDATE #{quoted_name} SET locked_at = ?, locked_by = ? WHERE id IN (#{subquery}) RETURNING *",
149
+ now,
150
+ worker.name
151
+ ]
152
+ ).first
137
153
  end
138
154
 
139
155
  def self.reserve_with_scope_using_optimized_mysql(ready_scope, worker, now)
@@ -172,13 +188,21 @@ module Delayed
172
188
  def self.db_time_now
173
189
  if Time.zone
174
190
  Time.zone.now
175
- elsif ::ActiveRecord::Base.default_timezone == :utc
191
+ elsif default_timezone == :utc
176
192
  Time.now.utc
177
193
  else
178
194
  Time.now # rubocop:disable Rails/TimeZone
179
195
  end
180
196
  end
181
197
 
198
+ def self.default_timezone
199
+ if ::ActiveRecord.respond_to?(:default_timezone)
200
+ ::ActiveRecord.default_timezone
201
+ else
202
+ ::ActiveRecord::Base.default_timezone
203
+ end
204
+ end
205
+
182
206
  def reload(*args)
183
207
  reset
184
208
  super
@@ -6,7 +6,14 @@ module DelayedJob
6
6
  # since ActiveRecord 3.0
7
7
  def next_migration_number(dirname)
8
8
  next_migration_number = current_migration_number(dirname) + 1
9
- if ActiveRecord::Base.timestamped_migrations
9
+ timestamped_migrations =
10
+ if ActiveRecord.respond_to?(:timestamped_migrations)
11
+ ActiveRecord.timestamped_migrations
12
+ else
13
+ ActiveRecord::Base.timestamped_migrations
14
+ end
15
+
16
+ if timestamped_migrations
10
17
  [Time.now.utc.strftime("%Y%m%d%H%M%S"), format("%.14d", next_migration_number)].max
11
18
  else
12
19
  format("%.3d", next_migration_number)
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.7
4
+ version: 4.1.10
5
5
  platform: ruby
6
6
  authors:
7
+ - David Genord II
7
8
  - Brian Ryckbost
8
9
  - Matt Griffin
9
10
  - Erik Michaels-Ober
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2022-01-18 00:00:00.000000000 Z
14
+ date: 2024-08-19 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: activerecord
@@ -55,6 +56,7 @@ dependencies:
55
56
  description: ActiveRecord backend for Delayed::Job, originally authored by Tobias
56
57
  Lütke
57
58
  email:
59
+ - david@collectiveidea.com
58
60
  - bryckbost@gmail.com
59
61
  - matt@griffinonline.org
60
62
  - sferik@gmail.com
@@ -93,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
95
  - !ruby/object:Gem::Version
94
96
  version: '0'
95
97
  requirements: []
96
- rubygems_version: 3.1.4
98
+ rubygems_version: 3.5.11
97
99
  signing_key:
98
100
  specification_version: 4
99
101
  summary: ActiveRecord backend for DelayedJob