waterdrop 2.6.8 → 2.6.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/lib/waterdrop/clients/rdkafka.rb +1 -0
- data/lib/waterdrop/config.rb +3 -2
- data/lib/waterdrop/instrumentation/callbacks/delivery.rb +53 -9
- data/lib/waterdrop/instrumentation/logger_listener.rb +5 -0
- data/lib/waterdrop/instrumentation/notifications.rb +2 -0
- data/lib/waterdrop/producer/transactions.rb +8 -3
- data/lib/waterdrop/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8108bc92f548809ab7220d8d36a03ceb72e283dd651d2d2fc0629bb81a36fc8
|
4
|
+
data.tar.gz: a9bbb98af4e8b1425082fd5816e1441c91a263acabbeb987b75d7d598fe72d8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e11745fc2986fcdc1ac8c5b4a8f4eeeb71c812b961eb296585e71d12d3601e9fcf124ad02d219db049f774a6417f6a293ce9cf5ce282ff5b70a05067fd310ec
|
7
|
+
data.tar.gz: 9488e3cf3753077bf790dbbd815889214dc0e66a4de871e460dd25a287ee3df309a14eed28969bf41cc77c76b4b3eaa64cd2c44a8f8f1556d78828cdf0a08659
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# WaterDrop changelog
|
2
2
|
|
3
|
+
## 2.6.10 (2023-10-24)
|
4
|
+
- [Improvement] Introduce `message.purged` event to indicate that a message that was not delivered to Kafka was purged. This most of the time refers to messages that were part of a transaction and were not yet dispatched to Kafka. It always means, that given message was not delivered but in case of transactions it is expected. In case of non-transactional it usually means `#purge` usage or exceeding `message.timeout.ms` so `librdkafka` removes this message from its internal queue. Non-transactional producers do **not** use this and pipe purges to `error.occurred`.
|
5
|
+
- [Fix] Fix a case where `message.acknowledged` would not have `caller` key.
|
6
|
+
- [Fix] Fix a bug where critical errors (like `IRB::Abort`) would not abort the ongoing transaction.
|
7
|
+
|
8
|
+
## 2.6.9 (2023-10-23)
|
9
|
+
- [Improvement] Introduce a `transaction.finished` event to indicate that transaction has finished whether it was aborted or committed.
|
10
|
+
- [Improvement] Use `transaction.committed` event to indicate that transaction has been committed.
|
11
|
+
|
3
12
|
## 2.6.8 (2023-10-20)
|
4
13
|
- **[Feature]** Introduce transactions support.
|
5
14
|
- [Improvement] Expand `LoggerListener` to inform about transactions (info level).
|
data/Gemfile.lock
CHANGED
data/lib/waterdrop/config.rb
CHANGED
@@ -64,9 +64,10 @@ module WaterDrop
|
|
64
64
|
# option [Numeric] how many seconds should we wait with the backoff on queue having space for
|
65
65
|
# more messages before re-raising the error.
|
66
66
|
setting :wait_timeout_on_queue_full, default: 10
|
67
|
-
|
67
|
+
# option [Numeric] How long to wait before retrying a retryable transaction related error
|
68
68
|
setting :wait_backoff_on_transaction_command, default: 0.5
|
69
|
-
|
69
|
+
# option [Numeric] How many times to retry a retryable transaction related error before
|
70
|
+
# giving up
|
70
71
|
setting :max_attempts_on_transaction_command, default: 5
|
71
72
|
|
72
73
|
# option [Boolean] should we send messages. Setting this to false can be really useful when
|
@@ -6,19 +6,41 @@ module WaterDrop
|
|
6
6
|
# Creates a callable that we want to run upon each message delivery or failure
|
7
7
|
#
|
8
8
|
# @note We don't have to provide client_name here as this callback is per client instance
|
9
|
+
#
|
10
|
+
# @note We do not consider `message.purge` as an error for transactional producers, because
|
11
|
+
# this is a standard behaviour for not yet dispatched messages on aborted transactions.
|
12
|
+
# We do however still want to instrument it for traceability.
|
9
13
|
class Delivery
|
14
|
+
# Error emitted when a message was not yet dispatched and was purged from the queue
|
15
|
+
RD_KAFKA_RESP_PURGE_QUEUE = -152
|
16
|
+
|
17
|
+
# Error emitted when a message was purged while it was dispatched
|
18
|
+
RD_KAFKA_RESP_PURGE_INFLIGHT = -151
|
19
|
+
|
20
|
+
# Errors related to queue purging that is expected in transactions
|
21
|
+
PURGE_ERRORS = [RD_KAFKA_RESP_PURGE_INFLIGHT, RD_KAFKA_RESP_PURGE_QUEUE].freeze
|
22
|
+
|
23
|
+
private_constant :RD_KAFKA_RESP_PURGE_QUEUE, :RD_KAFKA_RESP_PURGE_INFLIGHT, :PURGE_ERRORS
|
24
|
+
|
10
25
|
# @param producer_id [String] id of the current producer
|
26
|
+
# @param transactional [Boolean] is this handle for a transactional or regular producer
|
11
27
|
# @param monitor [WaterDrop::Instrumentation::Monitor] monitor we are using
|
12
|
-
def initialize(producer_id, monitor)
|
28
|
+
def initialize(producer_id, transactional, monitor)
|
13
29
|
@producer_id = producer_id
|
30
|
+
@transactional = transactional
|
14
31
|
@monitor = monitor
|
15
32
|
end
|
16
33
|
|
17
34
|
# Emits delivery details to the monitor
|
18
35
|
# @param delivery_report [Rdkafka::Producer::DeliveryReport] delivery report
|
19
36
|
def call(delivery_report)
|
20
|
-
|
37
|
+
error_code = delivery_report.error.to_i
|
38
|
+
|
39
|
+
if error_code.zero?
|
21
40
|
instrument_acknowledged(delivery_report)
|
41
|
+
|
42
|
+
elsif @transactional && PURGE_ERRORS.include?(error_code)
|
43
|
+
instrument_purged(delivery_report)
|
22
44
|
else
|
23
45
|
instrument_error(delivery_report)
|
24
46
|
end
|
@@ -27,24 +49,24 @@ module WaterDrop
|
|
27
49
|
private
|
28
50
|
|
29
51
|
# @param delivery_report [Rdkafka::Producer::DeliveryReport] delivery report
|
30
|
-
def
|
52
|
+
def instrument_acknowledged(delivery_report)
|
31
53
|
@monitor.instrument(
|
32
|
-
'
|
54
|
+
'message.acknowledged',
|
33
55
|
caller: self,
|
34
|
-
error: ::Rdkafka::RdkafkaError.new(delivery_report.error),
|
35
56
|
producer_id: @producer_id,
|
36
57
|
offset: delivery_report.offset,
|
37
58
|
partition: delivery_report.partition,
|
38
59
|
topic: delivery_report.topic_name,
|
39
|
-
delivery_report: delivery_report
|
40
|
-
type: 'librdkafka.dispatch_error'
|
60
|
+
delivery_report: delivery_report
|
41
61
|
)
|
42
62
|
end
|
43
63
|
|
44
64
|
# @param delivery_report [Rdkafka::Producer::DeliveryReport] delivery report
|
45
|
-
def
|
65
|
+
def instrument_purged(delivery_report)
|
46
66
|
@monitor.instrument(
|
47
|
-
'message.
|
67
|
+
'message.purged',
|
68
|
+
caller: self,
|
69
|
+
error: build_error(delivery_report),
|
48
70
|
producer_id: @producer_id,
|
49
71
|
offset: delivery_report.offset,
|
50
72
|
partition: delivery_report.partition,
|
@@ -52,6 +74,28 @@ module WaterDrop
|
|
52
74
|
delivery_report: delivery_report
|
53
75
|
)
|
54
76
|
end
|
77
|
+
|
78
|
+
# @param delivery_report [Rdkafka::Producer::DeliveryReport] delivery report
|
79
|
+
def instrument_error(delivery_report)
|
80
|
+
@monitor.instrument(
|
81
|
+
'error.occurred',
|
82
|
+
caller: self,
|
83
|
+
error: build_error(delivery_report),
|
84
|
+
producer_id: @producer_id,
|
85
|
+
offset: delivery_report.offset,
|
86
|
+
partition: delivery_report.partition,
|
87
|
+
topic: delivery_report.topic_name,
|
88
|
+
delivery_report: delivery_report,
|
89
|
+
type: 'librdkafka.dispatch_error'
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Builds appropriate rdkafka error
|
94
|
+
# @param delivery_report [Rdkafka::Producer::DeliveryReport] delivery report
|
95
|
+
# @return [::Rdkafka::RdkafkaError]
|
96
|
+
def build_error(delivery_report)
|
97
|
+
::Rdkafka::RdkafkaError.new(delivery_report.error)
|
98
|
+
end
|
55
99
|
end
|
56
100
|
end
|
57
101
|
end
|
@@ -145,6 +145,11 @@ module WaterDrop
|
|
145
145
|
info(event, 'Committing transaction')
|
146
146
|
end
|
147
147
|
|
148
|
+
# @param event [Dry::Events::Event] event that happened with the details
|
149
|
+
def on_transaction_finished(event)
|
150
|
+
info(event, 'Processing transaction')
|
151
|
+
end
|
152
|
+
|
148
153
|
private
|
149
154
|
|
150
155
|
# @return [Boolean] should we report the messages details in the debug mode.
|
@@ -12,6 +12,7 @@ module WaterDrop
|
|
12
12
|
message.produced_async
|
13
13
|
message.produced_sync
|
14
14
|
message.acknowledged
|
15
|
+
message.purged
|
15
16
|
message.buffered
|
16
17
|
|
17
18
|
messages.produced_async
|
@@ -21,6 +22,7 @@ module WaterDrop
|
|
21
22
|
transaction.started
|
22
23
|
transaction.committed
|
23
24
|
transaction.aborted
|
25
|
+
transaction.finished
|
24
26
|
|
25
27
|
buffer.flushed_async
|
26
28
|
buffer.flushed_sync
|
@@ -49,7 +49,7 @@ module WaterDrop
|
|
49
49
|
return yield if @transaction_mutex.owned?
|
50
50
|
|
51
51
|
@transaction_mutex.synchronize do
|
52
|
-
transactional_instrument(:
|
52
|
+
transactional_instrument(:finished) do
|
53
53
|
with_transactional_error_handling(:begin) do
|
54
54
|
transactional_instrument(:started) { client.begin_transaction }
|
55
55
|
end
|
@@ -65,11 +65,16 @@ module WaterDrop
|
|
65
65
|
commit || raise(WaterDrop::Errors::AbortTransaction)
|
66
66
|
|
67
67
|
with_transactional_error_handling(:commit) do
|
68
|
-
client.commit_transaction
|
68
|
+
transactional_instrument(:committed) { client.commit_transaction }
|
69
69
|
end
|
70
70
|
|
71
71
|
result
|
72
|
-
|
72
|
+
# We need to handle any interrupt including critical in order not to have the transaction
|
73
|
+
# running. This will also handle things like `IRB::Abort`
|
74
|
+
#
|
75
|
+
# rubocop:disable Lint/RescueException
|
76
|
+
rescue Exception => e
|
77
|
+
# rubocop:enable Lint/RescueException
|
73
78
|
with_transactional_error_handling(:abort) do
|
74
79
|
transactional_instrument(:aborted) { client.abort_transaction }
|
75
80
|
end
|
data/lib/waterdrop/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waterdrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
|
36
36
|
msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2023-10-
|
38
|
+
date: 2023-10-24 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: karafka-core
|
metadata.gz.sig
CHANGED
Binary file
|