solid_queue 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/app/models/solid_queue/blocked_execution.rb +2 -2
- data/app/models/solid_queue/execution/dispatching.rb +1 -1
- data/app/models/solid_queue/scheduled_execution.rb +1 -1
- data/app/models/solid_queue/semaphore.rb +5 -22
- data/lib/solid_queue/processes/registrable.rb +1 -1
- data/lib/solid_queue/version.rb +1 -1
- data/lib/solid_queue.rb +1 -1
- metadata +5 -7
- data/lib/active_job/uniqueness.rb +0 -41
- data/lib/solid_queue/dispatcher/scheduled_executions_dispatcher.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d907fb9133f2c72a61b586038f05b248a29e7c55f506aa541ca39f35a15d40ff
|
4
|
+
data.tar.gz: 887ecd7d0a15159ae10845466993699165a531367dbb21151e3ae704e56fa8e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665bb353c9cc8c557952ca5e2f63120b0541eef7a20008b6c288147e0350564200be2e6272f9924448867b9b2d09a7e48dc5b2267ec35b91f5dcd38bc409fff1
|
7
|
+
data.tar.gz: 9e911e1a270b5da57f75011e40ad6949480a8b87a2eb391934697159701273e1f05da9ac5c114e8d9dac492bb7685f6884eacac592ed44a460f513fd7349f85a
|
data/README.md
CHANGED
@@ -142,6 +142,7 @@ When receiving a `QUIT` signal, if workers still have jobs in-flight, these will
|
|
142
142
|
If processes have no chance of cleaning up before exiting (e.g. if someone pulls a cable somewhere), in-flight jobs might remain claimed by the processes executing them. Processes send heartbeats, and the supervisor checks and prunes processes with expired heartbeats, which will release any claimed jobs back to their queues. You can configure both the frequency of heartbeats and the threshold to consider a process dead. See the section below for this.
|
143
143
|
|
144
144
|
### Other configuration settings
|
145
|
+
_Note_: The settings in this section should be set in your `config/application.rb` or your environment config like this: `config.solid_queue.silence_polling = true`
|
145
146
|
|
146
147
|
There are several settings that control how Solid Queue works that you can set as well:
|
147
148
|
- `logger`: the logger you want Solid Queue to use. Defaults to the app logger.
|
@@ -161,7 +162,7 @@ There are several settings that control how Solid Queue works that you can set a
|
|
161
162
|
- `process_heartbeat_interval`: the heartbeat interval that all processes will follow—defaults to 60 seconds.
|
162
163
|
- `process_alive_threshold`: how long to wait until a process is considered dead after its last heartbeat—defaults to 5 minutes.
|
163
164
|
- `shutdown_timeout`: time the supervisor will wait since it sent the `TERM` signal to its supervised processes before sending a `QUIT` version to them requesting immediate termination—defaults to 5 seconds.
|
164
|
-
- `silence_polling`: whether to silence Active Record logs emitted when polling for both workers and dispatchers—defaults to `
|
165
|
+
- `silence_polling`: whether to silence Active Record logs emitted when polling for both workers and dispatchers—defaults to `true`.
|
165
166
|
- `supervisor_pidfile`: path to a pidfile that the supervisor will create when booting to prevent running more than one supervisor in the same host, or in case you want to use it for a health check. It's `nil` by default.
|
166
167
|
- `preserve_finished_jobs`: whether to keep finished jobs in the `solid_queue_jobs` table—defaults to `true`.
|
167
168
|
- `clear_finished_jobs_after`: period to keep finished jobs around, in case `preserve_finished_jobs` is true—defaults to 1 day. **Note:** Right now, there's no automatic cleanup of finished jobs. You'd need to do this by periodically invoking `SolidQueue::Job.clear_finished_in_batches`, but this will happen automatically in the near future.
|
@@ -228,8 +229,7 @@ failed_execution.retry # This will re-enqueue the job as if it was enqueued for
|
|
228
229
|
failed_execution.discard # This will delete the job from the system
|
229
230
|
```
|
230
231
|
|
231
|
-
|
232
|
-
|
232
|
+
However, we recommend taking a look at [mission_control-jobs](https://github.com/basecamp/mission_control-jobs), a dashboard where, among other things, you can examine and retry/discard failed jobs.
|
233
233
|
|
234
234
|
## Puma plugin
|
235
235
|
We provide a Puma plugin if you want to run the Solid Queue's supervisor together with Puma and have Puma monitor and manage it. You just need to add
|
@@ -30,10 +30,10 @@ module SolidQueue
|
|
30
30
|
|
31
31
|
private
|
32
32
|
def releasable(concurrency_keys)
|
33
|
-
semaphores = Semaphore.where(key: concurrency_keys).
|
33
|
+
semaphores = Semaphore.where(key: concurrency_keys).pluck(:key, :value).to_h
|
34
34
|
|
35
35
|
# Concurrency keys without semaphore + concurrency keys with open semaphore
|
36
|
-
(concurrency_keys - semaphores.keys) | semaphores.select { |
|
36
|
+
(concurrency_keys - semaphores.keys) | semaphores.select { |_key, value| value > 0 }.keys
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -10,7 +10,7 @@ module SolidQueue
|
|
10
10
|
jobs = Job.where(id: job_ids)
|
11
11
|
|
12
12
|
Job.dispatch_all(jobs).map(&:id).tap do |dispatched_job_ids|
|
13
|
-
where(job_id: dispatched_job_ids).delete_all
|
13
|
+
where(job_id: dispatched_job_ids).order(:job_id).delete_all
|
14
14
|
SolidQueue.logger.info("[SolidQueue] Dispatched #{dispatched_job_ids.size} jobs")
|
15
15
|
end
|
16
16
|
end
|
@@ -5,7 +5,7 @@ module SolidQueue
|
|
5
5
|
include Dispatching
|
6
6
|
|
7
7
|
scope :due, -> { where(scheduled_at: ..Time.current) }
|
8
|
-
scope :ordered, -> { order(scheduled_at: :asc, priority: :asc) }
|
8
|
+
scope :ordered, -> { order(scheduled_at: :asc, priority: :asc, job_id: :asc) }
|
9
9
|
scope :next_batch, ->(batch_size) { due.ordered.limit(batch_size) }
|
10
10
|
|
11
11
|
assumes_attributes_from_job :scheduled_at
|
@@ -26,7 +26,6 @@ module SolidQueue
|
|
26
26
|
|
27
27
|
def initialize(job)
|
28
28
|
@job = job
|
29
|
-
@retries = 0
|
30
29
|
end
|
31
30
|
|
32
31
|
def wait
|
@@ -42,42 +41,26 @@ module SolidQueue
|
|
42
41
|
end
|
43
42
|
|
44
43
|
private
|
45
|
-
attr_accessor :job
|
44
|
+
attr_accessor :job
|
46
45
|
|
47
46
|
def attempt_creation
|
48
47
|
Semaphore.create!(key: key, value: limit - 1, expires_at: expires_at)
|
49
48
|
true
|
50
49
|
rescue ActiveRecord::RecordNotUnique
|
51
|
-
|
50
|
+
if limit == 1 then false
|
51
|
+
else
|
52
|
+
attempt_decrement
|
53
|
+
end
|
52
54
|
end
|
53
55
|
|
54
56
|
def attempt_decrement
|
55
57
|
Semaphore.available.where(key: key).update_all([ "value = value - 1, expires_at = ?", expires_at ]) > 0
|
56
|
-
rescue ActiveRecord::Deadlocked
|
57
|
-
if retriable? then attempt_retry
|
58
|
-
else
|
59
|
-
raise
|
60
|
-
end
|
61
58
|
end
|
62
59
|
|
63
60
|
def attempt_increment
|
64
61
|
Semaphore.where(key: key, value: ...limit).update_all([ "value = value + 1, expires_at = ?", expires_at ]) > 0
|
65
62
|
end
|
66
63
|
|
67
|
-
def attempt_retry
|
68
|
-
self.retries += 1
|
69
|
-
|
70
|
-
if semaphore = Semaphore.find_by(key: key)
|
71
|
-
semaphore.value > 0 && attempt_decrement
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
MAX_RETRIES = 1
|
76
|
-
|
77
|
-
def retriable?
|
78
|
-
retries < MAX_RETRIES
|
79
|
-
end
|
80
|
-
|
81
64
|
def key
|
82
65
|
job.concurrency_key
|
83
66
|
end
|
data/lib/solid_queue/version.rb
CHANGED
data/lib/solid_queue.rb
CHANGED
@@ -33,7 +33,7 @@ module SolidQueue
|
|
33
33
|
|
34
34
|
mattr_accessor :shutdown_timeout, default: 5.seconds
|
35
35
|
|
36
|
-
mattr_accessor :silence_polling, default:
|
36
|
+
mattr_accessor :silence_polling, default: true
|
37
37
|
|
38
38
|
mattr_accessor :supervisor_pidfile
|
39
39
|
mattr_accessor :supervisor, default: false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solid_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rosa Gutierrez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- db/migrate/20240110143450_add_missing_index_to_blocked_executions.rb
|
102
102
|
- lib/active_job/concurrency_controls.rb
|
103
103
|
- lib/active_job/queue_adapters/solid_queue_adapter.rb
|
104
|
-
- lib/active_job/uniqueness.rb
|
105
104
|
- lib/generators/solid_queue/install/USAGE
|
106
105
|
- lib/generators/solid_queue/install/install_generator.rb
|
107
106
|
- lib/generators/solid_queue/install/templates/config.yml
|
@@ -110,7 +109,6 @@ files:
|
|
110
109
|
- lib/solid_queue/app_executor.rb
|
111
110
|
- lib/solid_queue/configuration.rb
|
112
111
|
- lib/solid_queue/dispatcher.rb
|
113
|
-
- lib/solid_queue/dispatcher/scheduled_executions_dispatcher.rb
|
114
112
|
- lib/solid_queue/engine.rb
|
115
113
|
- lib/solid_queue/pool.rb
|
116
114
|
- lib/solid_queue/processes/base.rb
|
@@ -126,12 +124,12 @@ files:
|
|
126
124
|
- lib/solid_queue/tasks.rb
|
127
125
|
- lib/solid_queue/version.rb
|
128
126
|
- lib/solid_queue/worker.rb
|
129
|
-
homepage:
|
127
|
+
homepage: https://github.com/basecamp/solid_queue
|
130
128
|
licenses:
|
131
129
|
- MIT
|
132
130
|
metadata:
|
133
|
-
homepage_uri:
|
134
|
-
source_code_uri:
|
131
|
+
homepage_uri: https://github.com/basecamp/solid_queue
|
132
|
+
source_code_uri: https://github.com/basecamp/solid_queue
|
135
133
|
post_install_message:
|
136
134
|
rdoc_options: []
|
137
135
|
require_paths:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveJob
|
4
|
-
module Uniqueness
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
DEFAULT_UNIQUENESS_GROUP = ->(*) { self.class.name }
|
8
|
-
|
9
|
-
included do
|
10
|
-
class_attribute :uniqueness_key, instance_accessor: false
|
11
|
-
class_attribute :uniqueness_group, default: DEFAULT_UNIQUENESS_GROUP, instance_accessor: false
|
12
|
-
|
13
|
-
class_attribute :uniqueness_duration
|
14
|
-
end
|
15
|
-
|
16
|
-
class_methods do
|
17
|
-
def enqueued_uniquely_by(key:, group: DEFAULT_UNIQUENESS_GROUP, duration: SolidQueue.default_uniqueness_period)
|
18
|
-
self.uniqueness_key = key
|
19
|
-
self.uniqueness_group = group
|
20
|
-
self.uniqueness_duration = duration
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def uniqueness_key
|
25
|
-
if self.class.uniqueness_key
|
26
|
-
param = compute_concurrency_parameter(self.class.concurrency_key)
|
27
|
-
|
28
|
-
case param
|
29
|
-
when ActiveRecord::Base
|
30
|
-
[ concurrency_group, param.class.name, param.id ]
|
31
|
-
else
|
32
|
-
[ concurrency_group, param ]
|
33
|
-
end.compact.join("/")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def enqueued_uniquely?
|
38
|
-
uniqueness_key.present?
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|