Skip to content

Commit 7a1397e

Browse files
authored
patch sticky rebalance protocol to mitigate endless loop issue (#493)
* patch rebalance * c * readme * backport of missing variable fix
1 parent a28aaef commit 7a1397e

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## 0.18.0 (Unreleased)
44
- [Enhancement] Update `librdkafka` to `2.5.0`
5+
- [Patch] Patch cooperative-sticky assignments in librdkafka.
56
- [Fix] Mitigate a case where FFI would not restart the background events callback dispatcher in forks
7+
- [Fix] Fix unused variable reference in producer (lucasmvnascimento)
68

79
## 0.17.0 (2024-08-03)
810
- [Feature] Add `#seek_by` to be able to seek for a message by topic, partition and offset (zinahia)

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ bundle exec rake produce_messages
163163

164164
| rdkafka-ruby | librdkafka | patches |
165165
|-|-|-|
166-
| 0.18.0 (Unreleased) | 2.5.0 (2024-06-10) | no |
167-
| 0.17.0 (2024-08-03) | 2.4.0 (2024-05-07) | no |
168-
| 0.16.0 (2024-06-13) | 2.3.0 (2023-10-25) | no |
169-
| 0.15.0 (2023-12-03) | 2.3.0 (2023-10-25) | no |
170-
| 0.14.0 (2023-11-21) | 2.2.0 (2023-07-12) | no |
171-
| 0.13.0 (2023-07-24) | 2.0.2 (2023-01-20) | no |
172-
| 0.12.0 (2022-06-17) | 1.9.0 (2022-06-16) | no |
173-
| 0.11.0 (2021-11-17) | 1.8.2 (2021-10-18) | no |
174-
| 0.10.0 (2021-09-07) | 1.5.0 (2020-07-20) | no |
166+
| 0.18.0 (Unreleased) | 2.5.0 (2024-06-10) | yes |
167+
| 0.17.0 (2024-08-03) | 2.4.0 (2024-05-07) | no |
168+
| 0.16.0 (2024-06-13) | 2.3.0 (2023-10-25) | no |
169+
| 0.15.0 (2023-12-03) | 2.3.0 (2023-10-25) | no |
170+
| 0.14.0 (2023-11-21) | 2.2.0 (2023-07-12) | no |
171+
| 0.13.0 (2023-07-24) | 2.0.2 (2023-01-20) | no |
172+
| 0.12.0 (2022-06-17) | 1.9.0 (2022-06-16) | no |
173+
| 0.11.0 (2021-11-17) | 1.8.2 (2021-10-18) | no |
174+
| 0.10.0 (2021-09-07) | 1.5.0 (2020-07-20) | no |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This patch is released under the 2-clause BSD license, same as librdkafka
2+
# Fixes: https://github.com/confluentinc/librdkafka/issues/4783
3+
#
4+
--- librdkafka_2.5.0/src/rdkafka_sticky_assignor.c 2024-07-08 09:47:43.000000000 +0200
5+
+++ librdkafka_2.5.0/src/rdkafka_sticky_assignor.c 2024-07-30 09:44:38.529759640 +0200
6+
@@ -769,7 +769,7 @@
7+
const rd_kafka_topic_partition_list_t *partitions;
8+
const char *consumer;
9+
const rd_map_elem_t *elem;
10+
- int i;
11+
+ int i, j;
12+
13+
/* The assignment is balanced if minimum and maximum numbers of
14+
* partitions assigned to consumers differ by at most one. */
15+
@@ -836,9 +836,9 @@
16+
17+
/* Otherwise make sure it can't get any more partitions */
18+
19+
- for (i = 0; i < potentialTopicPartitions->cnt; i++) {
20+
+ for (j = 0; j < potentialTopicPartitions->cnt; j++) {
21+
const rd_kafka_topic_partition_t *partition =
22+
- &potentialTopicPartitions->elems[i];
23+
+ &potentialTopicPartitions->elems[j];
24+
const char *otherConsumer;
25+
int otherConsumerPartitionCount;
26+

lib/rdkafka/producer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def produce(
298298
partitioner_name = @topics_configs.dig(topic, topic_config_hash, :partitioner) || @partitioner_name
299299

300300
# If the topic is not present, set to -1
301-
partition = Rdkafka::Bindings.partitioner(partition_key, partition_count, @partitioner_name) if partition_count.positive?
301+
partition = Rdkafka::Bindings.partitioner(partition_key, partition_count, partitioner_name) if partition_count.positive?
302302
end
303303

304304
# If partition is nil, use -1 to let librdafka set the partition randomly or

0 commit comments

Comments
 (0)