karafka 2.4.4 → 2.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b7333a7812643bc128c721e411449dfd477adfa52968c7c291900e622cdcc04
4
- data.tar.gz: 7062798152f0d4e097e5c4fcd228798103a680441579bbc1918c8bf5a65ce98b
3
+ metadata.gz: e550fa0b7395eab3b961181319d195809baeca82c02935d2735cf98353f6ef8b
4
+ data.tar.gz: f734562bfb86db59a64f4fbeb596bfe126eacd428a4ade00da90d238d959ab64
5
5
  SHA512:
6
- metadata.gz: bd24bd450ac1cda02d18d7d487317139988b943ecc92c606cb713f13c819db044d6feae978873d26445e1ebf8d8823bedfd7efae58bc53c8213be9ef56a84c1d
7
- data.tar.gz: 0f2f4b50ea90cd76f6275e0cdc9eeada5e5cd30bf6c18a219209dfe4b717d90ef88d7c6b68797e9eb0615c83ba03ee738d41164014ce74aaf27970ef07ba5974
6
+ metadata.gz: f80b521d063653c93caee987358573c992af2488ffec9c6465dbb04f9e51e8334548cf669b2b5f8f5783540be01fa8b52e067042cf72afda35f14181148ec87d
7
+ data.tar.gz: 32fd0f08102a2687f4b646d15cd07599f9aaefac957f828396af1f2d91bc91d5c922119bfec04d94cba63af86724d43cb50852de140d78e289fdbb612892dc78
checksums.yaml.gz.sig CHANGED
@@ -1 +1,4 @@
1
- zTS���?�D=���,��# ,
1
+ S ���#s�`&"�!p<�73�T�)��NU����3Ocv�1+.|�ò��9�n���g���S�u�{n )��G�"���>�<_�h�[o1�ECp<�|��\u&���O�{��BP��2�N>R*]��i�?k���.��Ua�V��P,P�X��,F�M�)+ᣦO1Lo� jI ���gr�
2
+ �&"E�)*��+̰�FE�H��͗:�mk��1p� $R��Jz�������򵦙���(�D� �Dt�8�W�����
3
+ �֝b��� DV�(�C�*��s�����J��@k��fL���x���
4
+ ה\��-���M����z���|EO��L�.-f���1�b��m~�X�-��&��X­8�
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.3
1
+ 3.3.4
data/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
- # Karafka framework changelog
1
+ # Karafka Framework Changelog
2
+
3
+ ## 2.4.6 (2024-07-22)
4
+ - [Fix] Mitigate `rd_kafka_cgrp_terminated` and other `librdkafka` shutdown issues by unsubscribing fully prior to shutdown.
5
+
6
+ ## 2.4.5 (2024-07-18)
7
+ - [Change] Inject `client.id` when building subscription group and not during the initial setup.
8
+ - [Fix] Mitigate `confluentinc/librdkafka/issues/4783` by injecting dynamic client id when using `cooperative-sticky` strategy.
9
+
10
+ ### Change Note
11
+
12
+ `client.id` is technically a low-importance value that should not (aside from this error) impact operations. This is why it is not considered a breaking change. This change may be reverted when the original issue is fixed in librdkafka.
2
13
 
3
14
  ## 2.4.4 (2024-07-04)
4
15
  - [Enhancement] Allow for offset storing from the Filtering API.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka (2.4.4)
4
+ karafka (2.4.6)
5
5
  base64 (~> 0.2)
6
6
  karafka-core (>= 2.4.3, < 2.5.0)
7
7
  waterdrop (>= 2.7.3, < 3.0.0)
@@ -39,13 +39,13 @@ GEM
39
39
  activesupport (>= 6.1)
40
40
  i18n (1.14.5)
41
41
  concurrent-ruby (~> 1.0)
42
- karafka-core (2.4.3)
43
- karafka-rdkafka (>= 0.15.0, < 0.17.0)
44
- karafka-rdkafka (0.16.0)
42
+ karafka-core (2.4.4)
43
+ karafka-rdkafka (>= 0.15.0, < 0.18.0)
44
+ karafka-rdkafka (0.17.0)
45
45
  ffi (~> 1.15)
46
46
  mini_portile2 (~> 2.6)
47
47
  rake (> 12)
48
- karafka-testing (2.4.4)
48
+ karafka-testing (2.4.5)
49
49
  karafka (>= 2.4.0, < 2.5.0)
50
50
  waterdrop (>= 2.7.0)
51
51
  karafka-web (0.9.1)
@@ -58,7 +58,7 @@ GEM
58
58
  minitest (5.24.0)
59
59
  mutex_m (0.2.0)
60
60
  ostruct (0.6.0)
61
- rack (3.1.4)
61
+ rack (3.1.5)
62
62
  rake (13.2.1)
63
63
  roda (3.81.0)
64
64
  rack
@@ -84,8 +84,8 @@ GEM
84
84
  tilt (2.4.0)
85
85
  tzinfo (2.0.6)
86
86
  concurrent-ruby (~> 1.0)
87
- waterdrop (2.7.3)
88
- karafka-core (>= 2.4.0, < 3.0.0)
87
+ waterdrop (2.7.4)
88
+ karafka-core (>= 2.4.3, < 3.0.0)
89
89
  karafka-rdkafka (>= 0.15.1)
90
90
  zeitwerk (~> 2.3)
91
91
  zeitwerk (2.6.16)
@@ -106,4 +106,4 @@ DEPENDENCIES
106
106
  simplecov
107
107
 
108
108
  BUNDLED WITH
109
- 2.5.14
109
+ 2.5.11
data/docker-compose.yml CHANGED
@@ -3,7 +3,7 @@ version: '2'
3
3
  services:
4
4
  kafka:
5
5
  container_name: kafka
6
- image: confluentinc/cp-kafka:7.6.1
6
+ image: confluentinc/cp-kafka:7.6.2
7
7
 
8
8
  ports:
9
9
  - 9092:9092
@@ -257,11 +257,15 @@ module Karafka
257
257
 
258
258
  # Gracefully stops topic consumption.
259
259
  def stop
260
- # In case of cooperative-sticky, there is a bug in librdkafka that may hang it.
261
- # To mitigate it we first need to unsubscribe so we will not receive any assignments and
262
- # only then we should be good to go.
260
+ # librdkafka has several constant issues when shutting down during rebalance. This is
261
+ # an issue that gets back every few versions of librdkafka in a limited scope, for example
262
+ # for cooperative-sticky or in a general scope. This is why we unsubscribe and wait until
263
+ # we no longer have any assignments. That way librdkafka consumer shutdown should never
264
+ # happen with rebalance associated with the given consumer instance
265
+ #
266
+ # @see https://github.com/confluentinc/librdkafka/issues/4792
263
267
  # @see https://github.com/confluentinc/librdkafka/issues/4527
264
- if @subscription_group.kafka[:'partition.assignment.strategy'] == 'cooperative-sticky'
268
+ if unsubscribe?
265
269
  unsubscribe
266
270
 
267
271
  until assignment.empty?
@@ -658,8 +662,13 @@ module Karafka
658
662
  subscriptions = @subscription_group.subscriptions
659
663
  assignments = @subscription_group.assignments(consumer)
660
664
 
661
- consumer.subscribe(*subscriptions) if subscriptions
662
- consumer.assign(assignments) if assignments
665
+ if subscriptions
666
+ consumer.subscribe(*subscriptions)
667
+ @mode = :subscribe
668
+ elsif assignments
669
+ consumer.assign(assignments)
670
+ @mode = :assign
671
+ end
663
672
 
664
673
  consumer
665
674
  end
@@ -690,6 +699,22 @@ module Karafka
690
699
  @kafka.start
691
700
  @kafka
692
701
  end
702
+
703
+ # Decides whether or not we should unsubscribe prior to closing.
704
+ #
705
+ # We cannot do it when there is a static group membership assignment as it would be
706
+ # reassigned.
707
+ # We cannot do it also for assign mode because then there are no subscriptions
708
+ # We also do not do it if there are no assignments at all as it does not make sense
709
+ #
710
+ # @return [Boolean] should we unsubscribe prior to shutdown
711
+ def unsubscribe?
712
+ return false if @subscription_group.kafka.key?(:'group.instance.id')
713
+ return false if @mode != :subscribe
714
+ return false if assignment.empty?
715
+
716
+ true
717
+ end
693
718
  end
694
719
  end
695
720
  end
@@ -121,8 +121,8 @@ module Karafka
121
121
  kafka = Setup::AttributesMap.consumer(@topics.first.kafka.dup)
122
122
 
123
123
  inject_group_instance_id(kafka)
124
+ inject_client_id(kafka)
124
125
 
125
- kafka[:'client.id'] ||= client_id
126
126
  kafka[:'group.id'] ||= @consumer_group.id
127
127
  kafka[:'auto.offset.reset'] ||= @topics.first.initial_offset
128
128
  # Karafka manages the offsets based on the processing state, thus we do not rely on the
@@ -132,6 +132,26 @@ module Karafka
132
132
  kafka
133
133
  end
134
134
 
135
+ # Sets (if needed) the client.id attribute
136
+ #
137
+ # @param kafka [Hash] kafka level config
138
+ def inject_client_id(kafka)
139
+ # If client id is set directly on librdkafka level, we do nothing and just go with what
140
+ # end user has configured
141
+ return if kafka.key?(:'client.id')
142
+
143
+ # This mitigates an issue for multiplexing and potentially other cases when running
144
+ # multiple karafka processes on one machine, where librdkafka goes into an infinite
145
+ # loop when using cooperative-sticky and upscaling.
146
+ #
147
+ # @see https://github.com/confluentinc/librdkafka/issues/4783
148
+ kafka[:'client.id'] = if kafka[:'partition.assignment.strategy'] == 'cooperative-sticky'
149
+ "#{client_id}/#{Time.now.to_f}/#{SecureRandom.hex[0..9]}"
150
+ else
151
+ client_id
152
+ end
153
+ end
154
+
135
155
  # If we use static group memberships, there can be a case, where same instance id would
136
156
  # be set on many subscription groups as the group instance id from Karafka perspective is
137
157
  # set per config. Each instance even if they are subscribed to different topics needs to
@@ -38,6 +38,7 @@ module Karafka
38
38
  default_topic_conf
39
39
  enable.auto.commit
40
40
  enable.auto.offset.store
41
+ enable.metrics.push
41
42
  enable.partition.eof
42
43
  enable.random.seed
43
44
  enable.sasl.oauthbearer.unsecure.jwt
@@ -89,6 +90,8 @@ module Karafka
89
90
  reconnect.backoff.max.ms
90
91
  reconnect.backoff.ms
91
92
  resolve_cb
93
+ retry.backoff.max.ms
94
+ retry.backoff.ms
92
95
  sasl.kerberos.keytab
93
96
  sasl.kerberos.kinit.cmd
94
97
  sasl.kerberos.min.time.before.relogin
@@ -182,6 +185,7 @@ module Karafka
182
185
  dr_msg_cb
183
186
  enable.gapless.guarantee
184
187
  enable.idempotence
188
+ enable.metrics.push
185
189
  enable.random.seed
186
190
  enable.sasl.oauthbearer.unsecure.jwt
187
191
  enable.ssl.certificate.verification
@@ -385,9 +385,6 @@ module Karafka
385
385
  config.kafka[key] = value
386
386
  end
387
387
 
388
- # Use Karafka client_id as kafka client id if not set
389
- config.kafka[:'client.id'] ||= config.client_id
390
-
391
388
  return if Karafka::App.env.production?
392
389
 
393
390
  KAFKA_DEV_DEFAULTS.each do |key, value|
@@ -3,5 +3,5 @@
3
3
  # Main module namespace
4
4
  module Karafka
5
5
  # Current Karafka version
6
- VERSION = '2.4.4'
6
+ VERSION = '2.4.6'
7
7
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.4.6
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: 2024-07-04 00:00:00.000000000 Z
38
+ date: 2024-07-22 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: base64
metadata.gz.sig CHANGED
Binary file