racecar 3.0.0.beta.1 → 3.0.0.beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da583e5664d52a322de9d5d1e94c21b1b95a5ddeecfa31c5c52878867c4568e5
4
- data.tar.gz: f35e00ca35831da9cfc0c5dbb6eebbe2404d8963ad62f2fb785a20e14aa5df08
3
+ metadata.gz: b0b740ff066f0f1aee2cd6bffac700badbbf684d2d9575c298aefe6a92a50d75
4
+ data.tar.gz: 022b4e5aea481beb637407cebe248c7890713a9ad64563edd316efca3f8ddfd6
5
5
  SHA512:
6
- metadata.gz: 0cbdae52223f76c0d7dbe6fb000522071789ee22deee87603cdab5947eca5842eafc8cc4053662d2152c8f18c841fb53a5872bc7e48c5b0596b82cf2ead0af0b
7
- data.tar.gz: 2ee11ff529c0043ec2b9bbc680f2da257775e9e6273236d9066df400d17c97ab02a7347f5a2c4687d56b00dc928178a9f1ec5c5c179c639fe6a5ae2ff2b505f5
6
+ metadata.gz: fb0f983b58a63ec97ae7f7a47b42cb47ff3a03907055b2c855305918b30964983c15882f806bff173acbbff224d22763331c8503366b0b7783af3ad9e7535dac
7
+ data.tar.gz: 4f95b4582e091c8543aeaf683f915a55880dc622d49f67a56c8dbac160531babcff640919804e555d971022035dfb865931c8d603433c2b5748cb9c11c5b7642
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- racecar (3.0.0.beta.1)
4
+ racecar (3.0.0.beta.2)
5
5
  concurrent-ruby (~> 1.3)
6
6
  king_konf (~> 1.0.0)
7
7
  rdkafka (>= 0.15.0)
@@ -82,4 +82,4 @@ DEPENDENCIES
82
82
  timecop
83
83
 
84
84
  BUNDLED WITH
85
- 2.6.2
85
+ 2.6.9
@@ -11,6 +11,10 @@ module Racecar
11
11
  "#{topic}/#{partition}"
12
12
  end
13
13
 
14
+ def thread_key
15
+ self.class.thread_key(@topic, @partition)
16
+ end
17
+
14
18
  def initialize(topic:, partition:, logger:, config:, consumer:, consumer_class:, instrumenter:, rdkafka_consumer:)
15
19
  @topic = topic
16
20
  @partition = partition
@@ -117,10 +121,6 @@ module Racecar
117
121
  end
118
122
  end
119
123
 
120
- def thread_key
121
- self.class.thread_key(@topic, @partition)
122
- end
123
-
124
124
  def main_processing_loop(block)
125
125
  loop do
126
126
  msgs = @queue.pop
@@ -49,6 +49,7 @@ module Racecar
49
49
  with_error_handling(message, payload) do |pause|
50
50
  @instrumenter.instrument("process_message", payload) do
51
51
  reconfigure_if_producer_closed!
52
+ exit_if_rebalancing!
52
53
  consumer_class_instance.process(Racecar::Message.new(message, retries_count: pause.pauses_count))
53
54
  consumer_class_instance.deliver!
54
55
  consumer.store_offset(message, @rdkafka_consumer) unless rebalancing
@@ -75,6 +76,7 @@ module Racecar
75
76
  Racecar::Message.new(message, retries_count: pause.pauses_count)
76
77
  end
77
78
  reconfigure_if_producer_closed!
79
+ exit_if_rebalancing!
78
80
  consumer_class_instance.process_batch(racecar_messages)
79
81
  consumer_class_instance.deliver!
80
82
  consumer.store_offset(messages.last, @rdkafka_consumer) unless rebalancing
@@ -142,14 +144,20 @@ module Racecar
142
144
  elsif !shutting_down
143
145
  handle_processing_error(e, payload, pause: pause)
144
146
  pause.pause!
145
- unless config.pause_timeout <= 0
146
- @sleep_mutex.synchronize do
147
- next if rebalancing || shutting_down
147
+
148
+ break if config.pause_timeout == 0
149
+
150
+ @sleep_mutex.synchronize do
151
+ next if rebalancing || shutting_down
152
+ if config.pause_timeout == -1
153
+ # Pause indefinitely. backoff_interval is Float::INFINITY here,
154
+ @sleep_cv.wait(@sleep_mutex)
155
+ else
148
156
  @sleep_cv.wait(@sleep_mutex, pause.backoff_interval)
149
157
  end
150
158
  end
151
159
  Thread.exit if rebalancing
152
- break if shutting_down || config.pause_timeout <= 0
160
+ break if shutting_down
153
161
  else
154
162
  handle_processing_error(e, payload, pause: pause)
155
163
  break
@@ -208,6 +216,14 @@ module Racecar
208
216
  reconfigure_consumer_class_instance!
209
217
  end
210
218
 
219
+ def exit_if_rebalancing!
220
+ return unless @config.multithreaded_processing_enabled
221
+ if rebalancing
222
+ logger.info "Exiting processing thread for #{topic}/#{partition} due to rebalancing"
223
+ Thread.exit
224
+ end
225
+ end
226
+
211
227
  def reconfigure_consumer_class_instance!
212
228
  consumer_class_instance.configure(
213
229
  producer: consumer.producer,
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rdkafka"
4
+ require "timeout"
4
5
  require "racecar/pause"
5
6
  require "racecar/message"
6
7
  require "racecar/message_delivery_error"
@@ -168,7 +169,9 @@ module Racecar
168
169
  processors_snapshot.each do |processor|
169
170
  if processor.respond_to?(:thread)
170
171
  begin
171
- processor.thread.join(config.multithreaded_processing_shutdown_timeout)
172
+ raise Timeout::Error unless processor.thread.join(config.multithreaded_processing_shutdown_timeout)
173
+ rescue Timeout::Error
174
+ logger.error "Processor thread for #{processor.thread_key} did not finish within #{config.multithreaded_processing_shutdown_timeout} seconds. It may be stuck in a long-running process or blocked on I/O."
172
175
  rescue => e
173
176
  logger.error "Error while waiting for processor thread to finish: #{e}"
174
177
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Racecar
4
- VERSION = "3.0.0.beta.1"
4
+ VERSION = "3.0.0.beta.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: racecar
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.1
4
+ version: 3.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck