sidekiq 1.1.3 → 1.1.4

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

Potentially problematic release.


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

data/Changes.md CHANGED
@@ -1,3 +1,11 @@
1
+ 1.1.4
2
+ -----------
3
+
4
+ - Add 24 hr expiry for basic keys set in Redis, to avoid any possible leaking.
5
+ - Only register workers in Redis while working, to avoid lingering
6
+ workers [#156]
7
+ - Speed up shutdown significantly.
8
+
1
9
  1.1.3
2
10
  -----------
3
11
 
@@ -39,7 +39,7 @@ module Sidekiq
39
39
  timeout = options[:timeout]
40
40
 
41
41
  @done = true
42
- @fetcher.terminate if @fetcher.alive?
42
+ @fetcher.terminate! if @fetcher.alive?
43
43
 
44
44
  logger.info { "Shutting down #{@ready.size} quiet workers" }
45
45
  @ready.each { |x| x.terminate if x.alive? }
@@ -155,7 +155,7 @@ module Sidekiq
155
155
  end
156
156
 
157
157
  def procline
158
- $0 = "sidekiq #{Sidekiq::VERSION} [#{@busy.size} of #{@count} busy]"
158
+ $0 = "sidekiq #{Sidekiq::VERSION} [#{@busy.size} of #{@count} busy]#{stopped? ? ' stopping' : ''}"
159
159
  after(5) { procline }
160
160
  end
161
161
  end
@@ -23,7 +23,6 @@ module Sidekiq
23
23
 
24
24
  def initialize(boss)
25
25
  @boss = boss
26
- redis {|x| x.sadd('workers', self) }
27
26
  end
28
27
 
29
28
  def process(msg, queue)
@@ -53,9 +52,10 @@ module Sidekiq
53
52
  def stats(worker, msg, queue)
54
53
  redis do |conn|
55
54
  conn.multi do
56
- conn.set("worker:#{self}:started", Time.now.to_s)
55
+ conn.sadd('workers', self)
56
+ conn.setex("worker:#{self}:started", DEFAULT_EXPIRY, Time.now.to_s)
57
57
  hash = {:queue => queue, :payload => msg, :run_at => Time.now.strftime("%Y/%m/%d %H:%M:%S %Z")}
58
- conn.set("worker:#{self}", Sidekiq.dump_json(hash))
58
+ conn.setex("worker:#{self}", DEFAULT_EXPIRY, Sidekiq.dump_json(hash))
59
59
  end
60
60
  end
61
61
 
@@ -69,13 +69,13 @@ module Sidekiq
69
69
  conn.multi do
70
70
  conn.incrby("stat:failed", 1)
71
71
  conn.del("stat:processed:#{self}")
72
- conn.srem("workers", self)
73
72
  end
74
73
  end
75
74
  raise
76
75
  ensure
77
76
  redis do |conn|
78
77
  conn.multi do
78
+ conn.srem("workers", self)
79
79
  conn.del("worker:#{self}")
80
80
  conn.del("worker:#{self}:started")
81
81
  conn.incrby("stat:processed", 1)
@@ -7,6 +7,8 @@ module Sidekiq
7
7
  #
8
8
  module Util
9
9
 
10
+ DEFAULT_EXPIRY = 24 * 60 * 60
11
+
10
12
  class Pretty < Logger::Formatter
11
13
  # Provide a call() method that returns the formatted message.
12
14
  def call(severity, time, program_name, message)
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
@@ -52,9 +52,8 @@ module Sidekiq
52
52
  Sidekiq.redis do |conn|
53
53
  conn.smembers('workers').map do |w|
54
54
  msg = conn.get("worker:#{w}")
55
- msg = Sidekiq.load_json(msg) if msg
56
- [w, msg]
57
- end.sort { |x| x[1] ? -1 : 1 }
55
+ msg ? [w, Sidekiq.load_json(msg)] : nil
56
+ end.compact.sort { |x| x[1] ? -1 : 1 }
58
57
  end
59
58
  end
60
59
  end
@@ -102,8 +101,7 @@ module Sidekiq
102
101
  end
103
102
 
104
103
  def current_status
105
- return 'down' if workers.size == 0
106
- return 'idle' if workers.size > 0 && workers.map { |x| x[1] }.compact.size == 0
104
+ return 'idle' if workers.size == 0
107
105
  return 'active'
108
106
  end
109
107
 
@@ -38,6 +38,13 @@ class TestManager < MiniTest::Unit::TestCase
38
38
  result = q.timed_pop(1.0)
39
39
  assert_equal 'done', result
40
40
  mgr.stop
41
+ mgr.terminate
42
+
43
+ # Gross bloody hack because I can't get the actor threads
44
+ # to shut down cleanly in the test. Need @bascule's help here.
45
+ (Thread.list - [Thread.current]).each do |t|
46
+ t.raise Interrupt
47
+ end
41
48
  end
42
49
  end
43
50
  end
@@ -29,11 +29,6 @@ class TestStats < MiniTest::Unit::TestCase
29
29
  processor = Sidekiq::Processor.new(boss)
30
30
  boss.expect(:processor_done!, nil, [processor])
31
31
 
32
- # adds to the workers set upon initialize
33
- set = conn.smembers('workers')
34
- assert_equal 1, set.size
35
- assert_match(/#{Regexp.escape(`hostname`.strip)}/, set.first)
36
-
37
32
  assert_equal 0, conn.get('stat:failed').to_i
38
33
  assert_equal 0, conn.get('stat:processed').to_i
39
34
  assert_equal 0, conn.get("stat:processed:#{processor}").to_i
@@ -42,9 +37,6 @@ class TestStats < MiniTest::Unit::TestCase
42
37
  processor.process(msg, 'xyzzy')
43
38
  processor.process(msg, 'xyzzy')
44
39
 
45
- set = conn.smembers('workers')
46
- assert_equal 1, set.size
47
- assert_match(/#{Regexp.escape(`hostname`.strip)}/, set.first)
48
40
  assert_equal 0, conn.get('stat:failed').to_i
49
41
  assert_equal 3, conn.get('stat:processed').to_i
50
42
  assert_equal 3, conn.get("stat:processed:#{processor}").to_i
@@ -61,15 +53,12 @@ class TestStats < MiniTest::Unit::TestCase
61
53
  assert_equal 0, conn.get('stat:processed').to_i
62
54
 
63
55
  processor = Sidekiq::Processor.new(boss)
64
- assert_equal 1, conn.smembers('workers').size
65
56
 
66
57
  pstr = processor.to_s
67
58
  assert_raises RuntimeError do
68
59
  processor.process(msg, 'xyzzy')
69
60
  end
70
61
 
71
- set = conn.smembers('workers')
72
- assert_equal 0, set.size
73
62
  assert_equal 1, conn.get('stat:failed').to_i
74
63
  assert_equal 1, conn.get('stat:processed').to_i
75
64
  assert_equal nil, conn.get("stat:processed:#{pstr}")
@@ -27,14 +27,14 @@ class TestWeb < MiniTest::Unit::TestCase
27
27
  it 'shows active queues' do
28
28
  get '/'
29
29
  assert_equal 200, last_response.status
30
- assert_match last_response.body, /Sidekiq is down/
30
+ assert_match last_response.body, /Sidekiq is idle/
31
31
  refute_match last_response.body, /default/
32
32
 
33
33
  assert WebWorker.perform_async(1, 2)
34
34
 
35
35
  get '/'
36
36
  assert_equal 200, last_response.status
37
- assert_match last_response.body, /Sidekiq is down/
37
+ assert_match last_response.body, /Sidekiq is idle/
38
38
  assert_match last_response.body, /default/
39
39
  refute_match last_response.body, /foo/
40
40
 
@@ -42,7 +42,7 @@ class TestWeb < MiniTest::Unit::TestCase
42
42
 
43
43
  get '/'
44
44
  assert_equal 200, last_response.status
45
- assert_match last_response.body, /Sidekiq is down/
45
+ assert_match last_response.body, /Sidekiq is idle/
46
46
  assert_match last_response.body, /default/
47
47
  assert_match last_response.body, /foo/
48
48
  end
@@ -3,13 +3,13 @@
3
3
  h1 Sidekiq is #{current_status}
4
4
  p Processed: #{processed}
5
5
  p Failed: #{failed}
6
- p Workers: #{workers.size}
6
+ p Busy Workers: #{workers.size}
7
7
  p Retries Pending: #{retry_count}
8
8
 
9
9
  .tabbable
10
10
  ul.nav.nav-tabs
11
11
  li.active
12
- a href="#workers" data-toggle="tab" Workers
12
+ a href="#workers" data-toggle="tab" Busy Workers
13
13
  li
14
14
  a href="#queues" data-toggle="tab" Queues
15
15
  li
@@ -26,13 +26,10 @@
26
26
  - workers.each do |(worker, msg)|
27
27
  tr
28
28
  td= worker
29
- - if msg
30
- td= msg['queue']
31
- td= msg['payload']['class']
32
- td= msg['payload']['args'].inspect[0..100]
33
- td== relative_time(Time.parse(msg['run_at']))
34
- - else
35
- td colspan=4 Idle
29
+ td= msg['queue']
30
+ td= msg['payload']['class']
31
+ td= msg['payload']['args'].inspect[0..100]
32
+ td== relative_time(Time.parse(msg['run_at']))
36
33
  form action="#{root_path}reset" method="post"
37
34
  button.btn type="submit" Clear worker list
38
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-23 00:00:00.000000000 Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70116788678440 !ruby/object:Gem::Requirement
16
+ requirement: &70161328001220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70116788678440
24
+ version_requirements: *70161328001220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redis-namespace
27
- requirement: &70116788677560 !ruby/object:Gem::Requirement
27
+ requirement: &70161328000340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70116788677560
35
+ version_requirements: *70161328000340
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: connection_pool
38
- requirement: &70116788676520 !ruby/object:Gem::Requirement
38
+ requirement: &70161327999200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70116788676520
46
+ version_requirements: *70161327999200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: celluloid
49
- requirement: &70116788675940 !ruby/object:Gem::Requirement
49
+ requirement: &70161327998620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.10.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70116788675940
57
+ version_requirements: *70161327998620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70116788675040 !ruby/object:Gem::Requirement
60
+ requirement: &70161327997960 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1.0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70116788675040
68
+ version_requirements: *70161327997960
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
- requirement: &70116788674260 !ruby/object:Gem::Requirement
71
+ requirement: &70161327996900 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70116788674260
79
+ version_requirements: *70161327996900
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sinatra
82
- requirement: &70116788673760 !ruby/object:Gem::Requirement
82
+ requirement: &70161327996420 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70116788673760
90
+ version_requirements: *70161327996420
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: slim
93
- requirement: &70116788689600 !ruby/object:Gem::Requirement
93
+ requirement: &70161328012260 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70116788689600
101
+ version_requirements: *70161328012260
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rake
104
- requirement: &70116788689140 !ruby/object:Gem::Requirement
104
+ requirement: &70161328011740 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70116788689140
112
+ version_requirements: *70161328011740
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: actionmailer
115
- requirement: &70116788688560 !ruby/object:Gem::Requirement
115
+ requirement: &70161328011180 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '3'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70116788688560
123
+ version_requirements: *70161328011180
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: activerecord
126
- requirement: &70116788688060 !ruby/object:Gem::Requirement
126
+ requirement: &70161328010660 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '3'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70116788688060
134
+ version_requirements: *70161328010660
135
135
  description: Simple, efficient message processing for Ruby
136
136
  email:
137
137
  - mperham@gmail.com