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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/racecar/async_partition_processor.rb +4 -4
- data/lib/racecar/partition_processor.rb +20 -4
- data/lib/racecar/runner.rb +4 -1
- data/lib/racecar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0b740ff066f0f1aee2cd6bffac700badbbf684d2d9575c298aefe6a92a50d75
|
|
4
|
+
data.tar.gz: 022b4e5aea481beb637407cebe248c7890713a9ad64563edd316efca3f8ddfd6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb0f983b58a63ec97ae7f7a47b42cb47ff3a03907055b2c855305918b30964983c15882f806bff173acbbff224d22763331c8503366b0b7783af3ad9e7535dac
|
|
7
|
+
data.tar.gz: 4f95b4582e091c8543aeaf683f915a55880dc622d49f67a56c8dbac160531babcff640919804e555d971022035dfb865931c8d603433c2b5748cb9c11c5b7642
|
data/Gemfile.lock
CHANGED
|
@@ -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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
|
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,
|
data/lib/racecar/runner.rb
CHANGED
|
@@ -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
|
data/lib/racecar/version.rb
CHANGED