inst-jobs 3.1.12 → 3.1.13

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: f195dab509c699ad54fc7d3a3a2de0d6b1d89496c16ac5cfe5d070468cb8f337
4
- data.tar.gz: 6b3d54760c5c54735676bf66e327b47ffe7fd04e4e56c3153f79814462ac7b34
3
+ metadata.gz: 2342458023c7d56e82311cd05089b8a748c266b462289a5ce5ba9c169a89abbe
4
+ data.tar.gz: b9cf5ced42b4a1d18f3599203c55683218c94d71c9f5671db58c8c49ba502ef6
5
5
  SHA512:
6
- metadata.gz: e571bbee3ce87f5b2f1a6d7991d7f1b7a8b6105babb1f53ef9ee1f5265a8dfa39fee12e2d942c67ccfa6eaa689e66934be08747913fdcea1f20d58bacc6c6290
7
- data.tar.gz: b9f49ac1a6c0b5845376da221368b8914a753ce58a4d53c4391eb46530b1e4216e48f9d2008302b8da77621f119562a84c6ce9394f5e17f450cd0398ad288cd1
6
+ metadata.gz: 5b234730e2acb907a880e564b8e7036ff64e9b3d09c18426779c125e7f7c2dbc83629d1c11157131137b0902a128f1a3cfba968e611a77e82782adabfdca6d96
7
+ data.tar.gz: d3487c737f65ced442c1219ae929eefd1247bb5753f345d06991634262fa592671ea37c798044b0477f038b2e2958c083bc38b9c5b4d344e9a557ec450cfb400
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Delayed
4
- VERSION = "3.1.12"
4
+ VERSION = "3.1.13"
5
5
  end
@@ -64,6 +64,7 @@ module Delayed
64
64
  @max_priority = options[:max_priority]
65
65
  @max_job_count = options[:worker_max_job_count].to_i
66
66
  @max_memory_usage = options[:worker_max_memory_usage].to_i
67
+ @memory_high_water = options[:worker_memory_high_water]&.to_i || (@max_memory_usage / 2)
67
68
  @work_queue = options.delete(:work_queue) || WorkQueue::InProcess.new
68
69
  @health_check_type = Settings.worker_health_check_type
69
70
  @health_check_config = Settings.worker_health_check_config
@@ -99,6 +100,11 @@ module Delayed
99
100
 
100
101
  def start
101
102
  logger.info "Starting worker"
103
+ begin
104
+ Process.setrlimit(:DATA, @max_memory_usage, @max_memory_usage * 2) if @max_memory_usage.positive?
105
+ rescue Errno::EINVAL
106
+ # couldn't set an OS-level limit
107
+ end
102
108
  self.process_name =
103
109
  "start:#{Settings.worker_procname_prefix}#{@queue_name}:#{min_priority || 0}:#{max_priority || "max"}"
104
110
  @self_pipe = IO.pipe
@@ -184,10 +190,10 @@ module Delayed
184
190
  @exit = true
185
191
  end
186
192
 
187
- if @max_memory_usage.positive?
193
+ if @memory_high_water.positive?
188
194
  memory = sample_memory
189
- if memory > @max_memory_usage
190
- logger.debug "Memory usage of #{memory} exceeds max of #{@max_memory_usage}, dying"
195
+ if memory > @memory_high_water
196
+ logger.debug "Memory usage of #{memory} exceeds high water of #{@memory_high_water}, dying"
191
197
  @exit = true
192
198
  else
193
199
  logger.debug "Memory usage: #{memory}"
@@ -233,6 +239,11 @@ module Delayed
233
239
  # still reschedule the job though.
234
240
  job.reschedule(e)
235
241
  rescue Exception => e # rubocop:disable Lint/RescueException
242
+ if e.is_a?(NoMemoryError)
243
+ GC.start # try and free up some memory before reporting the error
244
+ logger.debug "Could not allocate memory (max is #{@max_memory_usage}), dying"
245
+ @exit = true
246
+ end
236
247
  self.class.lifecycle.run_callbacks(:error, self, job, e) do
237
248
  handle_failed_job(job, e)
238
249
  end
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: 3.1.12
4
+ version: 3.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-09-07 00:00:00.000000000 Z
13
+ date: 2023-09-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord