resque 1.27.2 → 1.27.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of resque might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9757198382c0b8e5cf383fc49fe82ce4f59933e
4
- data.tar.gz: 6dbda5f17bf9cb44f99c18724b0cb6a6e1422e73
3
+ metadata.gz: 8cfae1b4e754004c51d8b6d06f5509ca5cdece1e
4
+ data.tar.gz: d2dd82dcb35a1f14c87aec745e7593e76530d791
5
5
  SHA512:
6
- metadata.gz: 45cc843a75953f9b5e08ebcded0caafa7da8a833489d6c48922b68d6fecc3192ddd4dbce3f77dffc45cf187a89e6a1e79509a2043e9ce11081996e8466561d75
7
- data.tar.gz: 6d5c2fdc451fd17b50b1d82a7f7ed94a25aad40af6cc0515e0cace4304944b0539fee3cc42c64a8608db64135fec5d79db0f9fb6c5f1d13531794923078c4f96
6
+ metadata.gz: 85e1e6529ca7966731a7b9e9d5fc2539c5ee6819ad721e37920d13f716af9b2f2459c808a46dfe2debe488d93b45f3efd11677e340317a59ba6f4f7b48cd9d6c
7
+ data.tar.gz: b14850616950503975ba128d33d3b190f5a21eff25236921e19cfdff990b07755ecd1ee9add5b3fc3fab8b905e7d700763102859d0699b0856bf1dd9c70bed19
data/HISTORY.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Nothing yet!
4
4
 
5
+ ## 1.27.3 (2017-04-10)
6
+
7
+ ### Fixed
8
+ * Fix issue where initializing a data store would attempt to hit Redis, even when Resque.inline = true
9
+
5
10
  ## 1.27.2 (2017-02-20)
6
11
 
7
12
  ### Fixed
@@ -450,6 +450,23 @@ If you want to stop processing jobs, but want to leave the worker running
450
450
  (for example, to temporarily alleviate load), use `USR2` to stop processing,
451
451
  then `CONT` to start it again.
452
452
 
453
+ #### Signals on Heroku
454
+
455
+ When shutting down processes, Heroku sends every process a TERM signal at the
456
+ same time. By default this causes an immediate shutdown of any running job
457
+ leading to frequent `Resque::TermException` errors. For short running jobs, a simple
458
+ solution is to give a small amount of time for the job to finish
459
+ before killing it.
460
+
461
+ To accomplish this set the following environment variables:
462
+
463
+ * `RESQUE_PRE_SHUTDOWN_TIMEOUT` - The time between the parent receiving a shutdown signal (TERM by default) and it sending that signal on to the child process. Designed to give the child process
464
+ time to complete before being forced to die.
465
+
466
+ * `TERM_CHILD` - Must be set for `RESQUE_PRE_SHUTDOWN_TIMEOUT` to be used. After the timeout, if the child is still running it will raise a `Resque::TermException` and exit.
467
+
468
+ * `RESQUE_TERM_TIMEOUT` - By default you have a few seconds to handle `Resque::TermException` in your job. `RESQUE_TERM_TIMEOUT` and `RESQUE_PRE_SHUTDOWN_TIMEOUT` must be lower than the [heroku dyno timeout](https://devcenter.heroku.com/articles/limits#exit-timeout).
469
+
453
470
  ### Mysql::Error: MySQL server has gone away
454
471
 
455
472
  If your workers remain idle for too long they may lose their MySQL connection. Depending on your version of Rails, we recommend the following:
@@ -840,8 +857,7 @@ send patches for any tweaks or improvements you can make to it.
840
857
  Questions
841
858
  ---------
842
859
 
843
- Please add them to the [FAQ](https://github.com/resque/resque/wiki/FAQ) or
844
- ask on the Mailing List. The Mailing List is explained further below
860
+ Please add them to the [FAQ](https://github.com/resque/resque/wiki/FAQ) or open an issue on this repo.
845
861
 
846
862
 
847
863
  Development
@@ -873,9 +889,6 @@ it:
873
889
  If you get an error requiring any of the dependencies, you may have
874
890
  failed to install them or be seeing load path issues.
875
891
 
876
- Feel free to ping the mailing list with your problem and we'll try to
877
- sort it out.
878
-
879
892
 
880
893
  Contributing
881
894
  ------------
@@ -894,11 +907,7 @@ Once you've made your great commits:
894
907
  Mailing List
895
908
  ------------
896
909
 
897
- To join the list simply send an email to <resque@librelist.com>. This
898
- will subscribe you and send you information about your subscription,
899
- including unsubscribe information.
900
-
901
- The archive can be found at <http://librelist.com/browser/resque/>.
910
+ This mailing list is no longer maintained. The archive can be found at <http://librelist.com/browser/resque/>.
902
911
 
903
912
 
904
913
  Meta
@@ -12,7 +12,6 @@ module Resque
12
12
  @failed_queue_access = FailedQueueAccess.new(@redis)
13
13
  @workers = Workers.new(@redis)
14
14
  @stats_access = StatsAccess.new(@redis)
15
- @redis_time_available = redis_time_available?
16
15
  end
17
16
 
18
17
  def_delegators :@queue_access, :push_to_queue,
@@ -92,14 +91,23 @@ module Resque
92
91
  end
93
92
 
94
93
  def server_time
95
- time, _ = @redis_time_available ? @redis.time : Time.now
94
+ time, _ = redis_time_available? ? @redis.time : Time.now
96
95
  Time.at(time)
97
96
  end
98
97
 
98
+ # only needed until support for Redis 2.4 is removed
99
99
  def redis_time_available?
100
- @redis.time
101
- rescue Redis::CommandError
102
- false
100
+ if @redis_time_available.nil? && !Resque.inline
101
+ begin
102
+ @redis_time_available = @redis.time
103
+ rescue Redis::CommandError
104
+ @redis_time_available = false
105
+ end
106
+ elsif Resque.inline
107
+ false
108
+ else
109
+ @redis_time_available
110
+ end
103
111
  end
104
112
  private :redis_time_available?
105
113
 
@@ -1,3 +1,3 @@
1
1
  module Resque
2
- Version = VERSION = '1.27.2'
2
+ Version = VERSION = '1.27.3'
3
3
  end
@@ -47,6 +47,10 @@ module Resque
47
47
 
48
48
  attr_accessor :term_timeout
49
49
 
50
+ attr_accessor :pre_shutdown_timeout
51
+
52
+ attr_accessor :term_child_signal
53
+
50
54
  # decide whether to use new_kill_child logic
51
55
  attr_accessor :term_child
52
56
 
@@ -144,7 +148,8 @@ module Resque
144
148
  verbose_value = ENV['LOGGING'] || ENV['VERBOSE']
145
149
  self.verbose = verbose_value if verbose_value
146
150
  self.very_verbose = ENV['VVERBOSE'] if ENV['VVERBOSE']
147
- self.term_timeout = ENV['RESQUE_TERM_TIMEOUT'] || 4.0
151
+ self.pre_shutdown_timeout = (ENV['RESQUE_PRE_SHUTDOWN_TIMEOUT'] || 0.0).to_f
152
+ self.term_timeout = (ENV['RESQUE_TERM_TIMEOUT'] || 4.0).to_f
148
153
  self.term_child = ENV['TERM_CHILD']
149
154
  self.graceful_term = ENV['GRACEFUL_TERM']
150
155
  self.run_at_exit_hooks = ENV['RUN_AT_EXIT_HOOKS']
@@ -396,11 +401,13 @@ module Resque
396
401
 
397
402
  def unregister_signal_handlers
398
403
  trap('TERM') do
399
- trap ('TERM') do
400
- # ignore subsequent terms
404
+ trap('TERM') do
405
+ # Ignore subsequent term signals
401
406
  end
407
+
402
408
  raise TermException.new("SIGTERM")
403
409
  end
410
+
404
411
  trap('INT', 'DEFAULT')
405
412
 
406
413
  begin
@@ -510,18 +517,26 @@ module Resque
510
517
 
511
518
  # Kills the forked child immediately with minimal remorse. The job it
512
519
  # is processing will not be completed. Send the child a TERM signal,
513
- # wait 5 seconds, and then a KILL signal if it has not quit
520
+ # wait <term_timeout> seconds, and then a KILL signal if it has not quit
521
+ # If pre_shutdown_timeout has been set to a positive number, it will allow
522
+ # the child that many seconds before sending the aforementioned TERM and KILL.
514
523
  def new_kill_child
515
524
  if @child
516
- unless Process.waitpid(@child, Process::WNOHANG)
525
+ unless child_already_exited?
526
+ if pre_shutdown_timeout && pre_shutdown_timeout > 0.0
527
+ log_with_severity :debug, "Waiting #{pre_shutdown_timeout.to_f}s for child process to exit"
528
+ return if wait_for_child_exit(pre_shutdown_timeout)
529
+ end
530
+
517
531
  log_with_severity :debug, "Sending TERM signal to child #{@child}"
518
532
  Process.kill("TERM", @child)
519
- (term_timeout.to_f * 10).round.times do |i|
520
- sleep(0.1)
521
- return if Process.waitpid(@child, Process::WNOHANG)
533
+
534
+ if wait_for_child_exit(term_timeout)
535
+ return
536
+ else
537
+ log_with_severity :debug, "Sending KILL signal to child #{@child}"
538
+ Process.kill("KILL", @child)
522
539
  end
523
- log_with_severity :debug, "Sending KILL signal to child #{@child}"
524
- Process.kill("KILL", @child)
525
540
  else
526
541
  log_with_severity :debug, "Child #{@child} already quit."
527
542
  end
@@ -530,6 +545,18 @@ module Resque
530
545
  log_with_severity :error, "Child #{@child} already quit and reaped."
531
546
  end
532
547
 
548
+ def child_already_exited?
549
+ Process.waitpid(@child, Process::WNOHANG)
550
+ end
551
+
552
+ def wait_for_child_exit(timeout)
553
+ (timeout * 10).round.times do |i|
554
+ sleep(0.1)
555
+ return true if child_already_exited?
556
+ end
557
+ false
558
+ end
559
+
533
560
  # are we paused?
534
561
  def paused?
535
562
  @paused
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.2
4
+ version: 1.27.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-02-20 00:00:00.000000000 Z
13
+ date: 2017-04-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: redis-namespace
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  requirements: []
188
188
  rubyforge_project:
189
- rubygems_version: 2.6.10
189
+ rubygems_version: 2.6.11
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: Resque is a Redis-backed queueing system.