karafka-rdkafka 0.28.0-aarch64-linux-gnu → 0.28.2-aarch64-linux-gnu

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: ed54b417d876a61e01603aebf12e29ec1b56a3f43cbae330d19aad1222f86d58
4
- data.tar.gz: a4925b7300fc077003ad5a588964902507a77152cc057e48cbf49beee5966522
3
+ metadata.gz: c55da5cc4ca09c9f37305039ff4e042da143270bbd2ca7be3e32821c2bab06c9
4
+ data.tar.gz: 06b1da56a0467dfecd246c9b32916875eac10f1adb050332a58da7063f02d169
5
5
  SHA512:
6
- metadata.gz: 5fe6ad75e784238e3781fe85eaff6bf36fdc2f4b7f5128c167a730d48607d17c10312ce3f5b9cac88ab47d0e841e72a3536cd5739bfa6b7a4c7de23934cec59d
7
- data.tar.gz: 78df953bd672fbf55a97ffa3372b1ccd3e2b8cd19d748d18f159ce5f92298101d40896e3e93721841f8d6e5c0e41f96c71f6503bd80df90760024cdfa853bc2e
6
+ metadata.gz: 68dada1abf386a99173495683243015e6910c1e9fdb06009f6496251aeefd7007395c199d50f48c17968ce982d03b8acc41dff5779fa14a28b822a6dabb0daab
7
+ data.tar.gz: 406ba779b17fb15d8384979ac9f58d666e020848ae973366905e37794c6e3bec3b2935e589ded09cf4fee40d3d1eb135fe9e0e82e9620311d87335c050db5760
data/CHANGELOG.md CHANGED
@@ -1,43 +1,59 @@
1
1
  # Rdkafka Changelog
2
2
 
3
- ## v0.28.0
3
+ ## 0.28.2 (2026-09-11)
4
+ - [Fix] Close live clients from an `at_exit` hook before Ruby's shutdown finalization, so librdkafka is no longer `dlclose`d while its native threads are still running (which could segfault on exit). Ported from rdkafka-ruby (#964, Alex Selesse).
5
+ - [Fix] Make client construction exception-safe and destroy the native handle when setup fails after `rd_kafka_new`, so a later error no longer orphans the native client. Ported from rdkafka-ruby (#964, Alex Selesse).
6
+ - [Fix] Destroy each polled message exactly once in `Consumer#poll_batch`/`#poll_batch_nb` when building a message raises a non-`RdkafkaError`, fixing a double-free that could abort the process and closing the matching leak window. Ported from rdkafka-ruby (#973).
7
+ - [Fix] Free the background queue, `AdminOptions` and any already-built `ConfigResource`s (and remove the handle) when `Admin#describe_configs`/`#incremental_alter_configs` raise while building native resources (e.g. a non-String resource name). Ported from rdkafka-ruby (#973).
8
+ - [Fix] Raise a clear `ConfigError` instead of segfaulting when `Admin#describe_configs`/`#incremental_alter_configs` are given an empty resource name or a negative resource type (`rd_kafka_ConfigResource_new` returns NULL), or when `rd_kafka_AdminOptions_new` returns NULL. Ported from rdkafka-ruby (#973).
9
+ - [Fix] Allocate the topic-partition metadata string with a process-global malloc instead of an autorelease-off `FFI::MemoryPointer`, so the buffer handed to librdkafka is not freed under it. Ported from rdkafka-ruby (#969, Randy Stauner).
10
+ - [Maintenance] Bump the bundled OpenSSL used by the precompiled builds to `3.5.8` (LTS). Ported from rdkafka-ruby (#972, Scott Francis).
11
+
12
+ ## v0.28.1 (2026-09-04)
13
+ - [Enhancement] Add `Admin#delete_records`, wrapping librdkafka's `DeleteRecords` admin API. Deletes all messages in a partition up to (but not including) a given offset - accepts an integer offset or `:end` to clear all current data. Ported from rdkafka-ruby (#956).
14
+ - [Enhancement] Add `Admin#list_consumer_groups`, wrapping librdkafka's `ListConsumerGroups` admin API. Returns a cluster-wide listing of consumer groups (`group_id`, `is_simple_consumer_group`, state) plus any per-broker errors. Ported from rdkafka-ruby (#955).
15
+ - [Fix] Make `NativeKafka#close` fork-aware so a forked child no longer segfaults on exit. Handles record their creator pid and skip the native teardown in any other process.
16
+ - [Fix] Stabilize the flaky partitions count cache statistics spec.
17
+ - [Fix] Stabilize the `to_native_tpl` leak integration spec against RSS measurement noise.
18
+
19
+ ## v0.28.0 (2026-07-12)
4
20
  - [Enhancement] Bump librdkafka to `2.14.2`. Maintenance release: fixes duplicate groups in `ListConsumerGroups` when multiple brokers return the same group, a data race in timers, and bumps bundled OpenSSL/libcurl/zstd/zlib/cJSON dependencies (several CVEs).
5
21
  - [Enhancement] Add `Consumer#metadata` and `Producer#metadata`, mirroring `Admin#metadata`, so cluster/topic metadata can be fetched from an existing consumer or producer handle without opening a dedicated admin connection.
6
22
  - [Enhancement] Name the failing partition and topic in the `RdkafkaError` raised for per-partition `list_offsets` errors (previously a bare error code), preserving the per-partition context the pre-batching `Consumer#lag` watermark errors carried.
7
- - [Enhancement] Add `Consumer#list_offsets`, mirroring `Admin#list_offsets`, so batched offset queries (one `ListOffsets` request carrying all requested partitions, fanned out to the partition leaders by librdkafka) can be issued on an existing consumer handle without opening a dedicated admin connection, and rebuild `Consumer#lag` on top of it: lag is now computed from a single batched end-offsets query instead of one blocking `query_watermark_offsets` broker roundtrip per partition. To receive the results, consumer clients now register the librdkafka background event callback, so librdkafka spawns its internally-managed background thread for consumers as well. `Consumer#lag` keeps its exact pre-batching semantics: it forwards the consumer's configured `isolation.level` to the batched query (librdkafka resolves the per-partition watermark query with that level, so end offsets stay LSO-based for the default `read_committed`), surfaces a timeout of the batched query as an `RdkafkaError` (`timed_out`), and now also raises `ClosedConsumerError` when called on a closed consumer.
8
- - [Enhancement] Extract the admin background-event result handlers into one class per operation under `lib/rdkafka/callbacks/` (`CreateTopicHandler`, `DescribeConfigsHandler`, etc., all subclasses of `Callbacks::BaseHandler`). `Callbacks::BackgroundEventCallback` is now a thin dispatcher that maps the event type to its handler and destroys the event. Purely internal reorganization (`Rdkafka::Callbacks` is private) with no behavior or API change.
9
- - [Enhancement] Expose `replicas` and `isrs` (in-sync replica broker ids) on each partition in topic metadata (`Metadata#topics` partition hashes). The base struct `#to_h` skips FFI pointer members, so these two arrays were dropped entirely and the partition replica assignment was unavailable to callers (e.g. for planning replication-factor changes). `PartitionMetadata#to_h` now dereferences both pointers into arrays of broker ids.
10
- - [Enhancement] Reuse per-thread scratch pointers in `Consumer::Headers.from_native` instead of allocating them for every consumed message. Previously each message paid one native pointer allocation just to check for headers and three more when headers were present; now the scratch pointers are allocated once per thread/fiber and reused, removing all per-message native scratch allocations from the consumer hot path.
11
- - [Enhancement] Remove the unused `DeliveryHandle` `:topic_name` struct field and the per-message allocation that populated it. The delivery callback copied the topic name into a native `FFI::MemoryPointer` on every delivered message, retained for the lifetime of the handle, yet nothing ever read it: the topic is already available via `DeliveryHandle#topic` (a Ruby attribute set during `produce`) and `DeliveryReport#topic_name`, both of which work exactly as before.
12
- - [Fix] Stop `poll_batch`/`poll_batch_nb` from discarding a whole batch when one message fails to build. If building a `Consumer::Message` raised (e.g. a header-read `RdkafkaError`), the exception propagated out of the batch loop and the `ensure` destroyed every remaining message, so all the messages already built in that batch were lost even though their offsets had been stored - permanent silent loss of up to `max_items` messages. A per-message build error is now surfaced inline as an `RdkafkaError` in the returned array (the same way native error events already are), so the rest of the batch is preserved and the failure is visible to the caller. (Single-message `poll`/`poll_nb` still raise as before.)
13
- - [Fix] Add the missing `closed_consumer_check` to `Consumer#position`. Every sibling offset method guards against a closed consumer, but `position` did not: with an explicit `list` it raised `ClosedInnerError` instead of `ClosedConsumerError`, and with no `list` it raised `ClosedConsumerError` naming `assignment` rather than `position`. It now raises a consistent `ClosedConsumerError` for `position`.
14
- - [Fix] Stop leaking the native `rd_kafka_topic_conf_t` in `Producer#set_topic_config` when a per-topic config value is rejected. The conf is built with `rd_kafka_topic_conf_new` and only handed to `rd_kafka_topic_new` afterwards; if `rd_kafka_topic_conf_set` returned a non-`:config_ok` result the method raised before `rd_kafka_topic_new` was ever called, so librdkafka never took ownership of the conf and it leaked (repeatable per produce with an invalid `topic_config:`). The conf is now destroyed before raising. The `rd_kafka_topic_new` path is unchanged: librdkafka frees the conf there on both success and failure, so it is never destroyed by us.
15
- - [Fix] Raise instead of silently dropping a rejected `incremental_alter_configs` entry. `rd_kafka_ConfigResource_add_incremental_config` returns an `rd_kafka_error_t` for an invalid op_type, an empty/nil name, or a nil value on a non-delete op; the result was ignored, so the entry was dropped, the alter request still reported success, and the error object leaked. The error is now surfaced as an `RdkafkaError` (raised before the request is sent) and the native error object is freed.
16
- - [Fix] Let `PartitionsCountCache` adopt a lower partition count once the cached entry has expired. The cache prioritizes higher counts (partition counts only grow during normal operation), but it did so unconditionally: after the TTL expired it fetched the true lower count, discarded it, and re-armed the TTL on the stale higher count - permanently. A topic recreated with fewer partitions then made `produce` (with a partition key) fail with `unknown_partition` for the dropped partitions until process restart. A lower value is now adopted on the first refresh after expiry, while still being ignored within the TTL window so a transient or racy lower read cannot clobber a correct higher count.
17
- - [Fix] Make the `Consumer` GC finalizer close the consumer and destroy its consumer queue, not just the native client. The finalizer used the generic `NativeKafka` one, which went straight to `rd_kafka_destroy` and skipped `rd_kafka_consumer_close` and `rd_kafka_queue_destroy`. A consumer that used `poll_batch` (which takes a consumer-queue reference) and was then garbage-collected without an explicit `close` left that reference dangling, which could make `rd_kafka_destroy` block inside the finalizer (process hang at GC/shutdown) or leak the handle. The consumer now installs its own finalizer that mirrors `#close` (the queue pointer is shared with the finalizer via a holder so it never captures the consumer and prevents collection).
18
- - [Fix] Stop admin operations from leaking when their arguments are rejected. `describe_configs` and `incremental_alter_configs` allocated the background queue and AdminOptions and registered their handle before parsing input, so a missing key raised a `KeyError` out of the building loop that orphaned the handle in the process-global registry forever (and leaked the queue, AdminOptions and any `ConfigResource`s already built); `list_offsets` likewise allocated its native topic-partition list before validating the offset specs. All three now parse and validate input up front, so a bad argument raises with nothing allocated.
19
- - [Fix] Destroy the native topic-partition list in `TopicPartitionList#to_native_tpl` when population fails partway. The list is allocated with `rd_kafka_topic_partition_list_new` and only handed back (for the caller to destroy) on success; if building it raised - e.g. a non-string metadata value or an offset FFI cannot coerce to int64 - the half-built list leaked, since destruction is fully manual (the previous doc comment claiming GC handled it was wrong). It is now destroyed before the error propagates.
20
- - [Fix] Allocate the admin result-count out-parameter as `:size_t` instead of `:int32`. Every librdkafka `rd_kafka_*_result_*(result, size_t *cntp)` accessor writes a full native `size_t` (8 bytes on 64-bit), but the count pointer was a 4-byte `FFI::MemoryPointer.new(:int32)` across the create/delete topic, create partitions, create/delete ACL, describe/incremental-alter configs and config-synonyms paths - a 4-byte heap overflow on every admin result parse (benign on little-endian, where the low word still reads the correct count, but undefined behavior). Now uses `:size_t`, matching the already-correct list-offsets and `get_err_descs` paths.
21
- - [Fix] Destroy admin API background events after processing. librdkafka requires the application to destroy each background event, but `rd_kafka_event_destroy` was never called (nor even bound), so every admin operation leaked its entire result event with all result arrays and strings. Reports are now built inside the callback (copying event-owned memory into Ruby objects) before the event is destroyed, and `DescribeConfigsReport`/`IncrementalAlterConfigsReport` no longer destroy the event-owned ConfigResource array, which also fixes a double free on repeated `wait` calls on the same handle. As part of this, the internal FFI struct fields on admin operation handles (e.g. `handle[:error_string]`, `handle[:result_name]`, `handle[:config_entries]`, `handle[:response_string]`, `handle[:matching_acls]`) were removed; they were never part of the public API (use `handle.wait` and the returned report objects, whose interfaces are unchanged).
22
- - [Fix] Resolve admin operation handles from the event error when an admin operation fails at the operation level (e.g. brokers unreachable, or the client closed with the request in flight). librdkafka delivers such failures as a result event with the error set and an empty results array, but the create topic, delete topic, create partitions, delete groups, create ACL and delete ACL handlers indexed `results[0]` unconditionally. That raised inside the background event callback, so the handle was never unlocked and `wait` blocked until its own timeout and raised `WaitTimeoutError`, discarding the real error. These handlers now check the event error first and resolve the handle with the actual error code (the describe configs, incremental alter configs, describe ACL and list offsets handlers already did).
23
- - [Fix] Stop leaking the native `rd_kafka_conf_t` when client creation fails. `native_config` raised `ConfigError` mid-build (e.g. on an invalid option) without destroying the conf, and `native_kafka` raised `ClientCreationError` on a null `rd_kafka_new` without destroying it either. Both paths now call `rd_kafka_conf_destroy` before re-raising (librdkafka keeps app ownership of the conf on `rd_kafka_new` failure, so this is safe). Multi-KB leak per failed creation, relevant for supervisors retrying client creation on transient SASL/SSL misconfig.
24
- - [Fix] Stop `Metadata` from leaking the native metadata struct (and a topic reference) on every retried fetch. `retry` restarts the `begin` block without running its `ensure`, so each retried attempt reassigned the pointers and only the last attempt's `rd_kafka_metadata` struct was ever destroyed; up to `METADATA_MAX_RETRIES` whole-cluster structs leaked per call (the `leader_not_available` case is routine during topic creation/leader election). Each attempt now frees its own native resources, and a failed fetch that never allocated a struct no longer calls `rd_kafka_metadata_destroy` on a NULL pointer.
25
- - [Fix] Free the librdkafka-allocated string in `Consumer#cluster_id` and `Consumer#member_id` (previously copied via a `:string` binding but never freed) and fix the `rd_kafka_clusterid` arity to pass `timeout_ms`. `Consumer#cluster_id` now accepts a `timeout_ms` (default `Defaults::CONSUMER_CLUSTER_ID_TIMEOUT_MS`).
26
- - [Fix] Guard the message delivery callback so a raising user `delivery_callback` can no longer skip the handle unlock or crash the producer. `DeliveryCallback` invoked the user callback and only then unlocked the handle, with no rescue; if the callback raised, the handle stayed pending (so `wait` blocked until its timeout and raised `WaitTimeoutError` for a message that was actually delivered) and the exception unwound out of the FFI callback on librdkafka's polling thread (`abort_on_exception = true`), taking down the whole process. The user callback is now wrapped so exceptions are logged and swallowed (matching the rebalance callback) and the handle is always unlocked in an `ensure`.
27
- - [Fix] Stop `Producer#produce` from orphaning the delivery handle in the process-global registry when it fails after registering it. The handle was only removed on a non-zero `rd_kafka_producev` return, so any exception between registration and that check (a concurrent `close` making `with_inner` raise `ClosedInnerError`, or a header value whose `#to_s` raises) leaked the handle forever - it survives producer close and accumulates in apps that recreate/close producers. `produce` now removes the handle on any such failure before re-raising.
28
- - [Fix] Attach `rd_kafka_query_watermark_offsets` with `blocking: true` so it releases the GVL during its broker round-trip. It was the only synchronous network call bound without the flag, so `Consumer#query_watermark_offsets` (and `Consumer#lag`, which calls it once per partition) froze every other Ruby thread in the process - including producer polling threads - for up to `timeout_ms`. Matches the neighboring `rd_kafka_offsets_for_times` binding.
29
- - [Fix] Stabilize the flaky `Consumer#lag` "calculates the consumer lag" spec on overloaded CI. The manual `consumer.commit` could raise `no_offset` when the default 5s background auto-commit had already committed the stored offsets, or when the auto offset store had not yet caught up with `poll`. The spec now raises `auto.commit.interval.ms` to 60s (matching the existing `#seek`/pause specs) and lets the offset store settle before committing. Backported from rdkafka-ruby (#912).
30
- - [Fix] Fix the NULL background-queue cleanup branches in `Admin#delete_group`, `Admin#delete_acl` and `Admin#describe_acl`, which referenced undefined local variables (`delete_topic_ptr`/`new_acl_ptr`). When `rd_kafka_queue_get_background` returned NULL, those branches raised a `NameError` instead of the intended `ConfigError` and leaked the already-allocated native request object (the `rd_kafka_DeleteGroup_t` / ACL binding filter), and `delete_group` additionally called the wrong destructor. They now destroy the correct object and raise `ConfigError`.
31
- - [Fix] Forward `broker_message` and `instance_name` through `RdkafkaError.build`. On the `rd_kafka_error_t` pointer path `build` called `build_from_c` without passing either, so a caller-supplied broker message was discarded (falling back to `rd_kafka_err2str`) and the instance name was lost; the `Bindings::Message` path also dropped `instance_name`. Both are now forwarded, and `build_from_c` accepts `instance_name`.
32
- - [Fix] Synchronize `AbstractHandle::REGISTRY` mutations. The handle registry is a plain Hash mutated from producing/consuming threads and the background polling thread (which removes handles from FFI callbacks). That is effectively safe on MRI under the GVL but not on JRuby, where a lost write could leave a handle unregistered (never unlocked, so `wait` times out for a delivered message) or never removed (permanent leak). `register`/`remove` now guard the Hash with a mutex.
33
- - [Fix] Stop the `Metadata` retry loop from clobbering the request timeout and blocking for minutes. Each retry overwrote the per-request timeout with the exponential backoff value, so the first retries ran with a far-too-short request timeout (e.g. 200ms vs the 2,000ms default, near-guaranteeing another timeout) while later ones inflated it to ~100s; the cumulative sleeps alone reached ~204s. The request timeout is now left unchanged across retries, the per-attempt backoff is capped at `Defaults::METADATA_RETRY_BACKOFF_MAX_MS` (1,000ms), and the loop is bounded by a wall-clock budget (`Defaults::METADATA_RETRY_BUDGET_MS`, 5,000ms) after a floor of `Defaults::METADATA_MIN_ATTEMPTS` (3) tries. This keeps a synchronous metadata fetch from blocking for minutes while still giving a slow broker a few attempts: fast-recovering clusters retry quickly within the budget, an unresponsive one fails in ~5s (a bit over if its requests each consume the full timeout), and at least 3 attempts always happen.
34
- - [Fix] Cache the partition count for a missing topic so `produce` with a `partition_key` to a not-yet-created topic no longer runs a blocking metadata query on every message. The `unknown_topic_or_part` result was resolved to `RD_KAFKA_PARTITION_UA` outside the partition-count cache, so nothing was stored and each call performed a fresh synchronous metadata RPC (the promised negative cache did not exist). The miss is now resolved inside the cache block, so it is cached like any other value and reused for the cache TTL.
23
+ - [Enhancement] Add `Consumer#list_offsets`, mirroring `Admin#list_offsets`, so offsets can be queried on an existing consumer handle without a dedicated admin connection, and rebuild `Consumer#lag` on top of it as one batched query instead of a roundtrip per partition.
24
+ - [Enhancement] Extract the admin background-event result handlers into one class per operation under `lib/rdkafka/callbacks/`. Internal reorganization with no API or behavior change.
25
+ - [Enhancement] Expose `replicas` and `isrs` (in-sync replica broker ids) on each partition in topic metadata; both were previously dropped from the `Metadata#topics` partition hashes.
26
+ - [Enhancement] Reuse per-thread scratch pointers in `Consumer::Headers.from_native`, removing the per-message native allocations from the consumer hot path.
27
+ - [Enhancement] Remove the unused `DeliveryHandle` `:topic_name` struct field and its per-message allocation. Use `DeliveryHandle#topic` or `DeliveryReport#topic_name`, both unchanged.
28
+ - [Fix] Stop `poll_batch`/`poll_batch_nb` from discarding a whole batch when one message fails to build. The failure is now surfaced inline as an `RdkafkaError` in the returned array, preserving the rest of the batch.
29
+ - [Fix] Add the missing `closed_consumer_check` to `Consumer#position`, so it raises a consistent `ClosedConsumerError` like every sibling offset method.
30
+ - [Fix] Stop leaking the native `rd_kafka_topic_conf_t` in `Producer#set_topic_config` when a per-topic config value is rejected.
31
+ - [Fix] Raise instead of silently dropping a rejected `incremental_alter_configs` entry, which previously left the alter request reporting success.
32
+ - [Fix] Let `PartitionsCountCache` adopt a lower partition count once the cached entry has expired, so a topic recreated with fewer partitions no longer fails `produce` until process restart.
33
+ - [Fix] Make the `Consumer` GC finalizer close the consumer and destroy its consumer queue, not just the native client, preventing a hang or leak when a consumer is collected without an explicit `close`.
34
+ - [Fix] Stop `describe_configs`, `incremental_alter_configs` and `list_offsets` from leaking handles and native resources when their arguments are rejected; all three now validate input before allocating.
35
+ - [Fix] Destroy the native topic-partition list in `TopicPartitionList#to_native_tpl` when population fails partway, which previously leaked the half-built list.
36
+ - [Fix] Allocate the admin result-count out-parameter as `:size_t` instead of `:int32`, fixing a 4-byte overflow on every admin result parse.
37
+ - [Fix] Destroy admin API background events after processing; they were never destroyed, so every admin operation leaked its whole result event. The internal FFI struct fields on admin handles were removed as part of this - use `handle.wait` and the returned report objects, whose interfaces are unchanged.
38
+ - [Fix] Resolve admin operation handles from the event error when an operation fails at the operation level (e.g. brokers unreachable), instead of blocking until `wait` timed out and discarding the real error.
39
+ - [Fix] Stop leaking the native `rd_kafka_conf_t` when client creation fails, a multi-KB leak per failed attempt for supervisors retrying on transient SASL/SSL misconfiguration.
40
+ - [Fix] Stop `Metadata` from leaking the native metadata struct on every retried fetch; each attempt now frees its own native resources.
41
+ - [Fix] Free the librdkafka-allocated string in `Consumer#cluster_id` and `Consumer#member_id`, and fix the `rd_kafka_clusterid` arity. `Consumer#cluster_id` now accepts a `timeout_ms`.
42
+ - [Fix] Guard the message delivery callback so a raising user `delivery_callback` can no longer leave the handle locked or crash the producer; exceptions are now logged and swallowed.
43
+ - [Fix] Stop `Producer#produce` from orphaning the delivery handle in the process-global registry when it fails after registering it.
44
+ - [Fix] Attach `rd_kafka_query_watermark_offsets` with `blocking: true` so it releases the GVL; it previously froze every other Ruby thread for up to `timeout_ms`.
45
+ - [Fix] Stabilize the flaky `Consumer#lag` spec on overloaded CI. Backported from rdkafka-ruby (#912).
46
+ - [Fix] Fix the NULL background-queue cleanup branches in `Admin#delete_group`, `Admin#delete_acl` and `Admin#describe_acl`, which raised a `NameError` and leaked the native request object instead of raising `ConfigError`.
47
+ - [Fix] Forward `broker_message` and `instance_name` through `RdkafkaError.build`; both were previously discarded on the `rd_kafka_error_t` pointer path.
48
+ - [Fix] Synchronize `AbstractHandle::REGISTRY` mutations with a mutex, which could otherwise lose a write on JRuby and leave a handle unregistered or leaked.
49
+ - [Fix] Stop the `Metadata` retry loop from clobbering the request timeout and blocking for minutes. The request timeout is left unchanged across retries, the backoff is capped, and the loop is bounded by a ~5s wall-clock budget after a floor of 3 attempts.
50
+ - [Fix] Cache the partition count for a missing topic, so `produce` with a `partition_key` to a not-yet-created topic no longer runs a blocking metadata query on every message.
35
51
 
36
52
  ## 0.27.2 (2026-05-21)
37
53
  - [Enhancement] `poll_batch` and `poll_batch_nb` now return error events inline as `RdkafkaError` objects rather than raising on the first error. The return type is `Array<Message, RdkafkaError>` and callers are responsible for handling errors in the result.
38
54
 
39
55
  ## 0.27.1 (2026-05-14)
40
- - [Fix] `poll_nb`, `poll_nb_each`, `poll_batch`, and `poll_batch_nb` now raise `RdkafkaError` with `details` populated (`{topic:, partition:, offset:}`) when a message contains an error (e.g. `:partition_eof`). Previously these methods raised via `RdkafkaError.new(code)`, discarding the native message struct context. They now use `RdkafkaError.validate!(native_message, client_ptr: inner)`, consistent with `poll`.
56
+ - [Fix] `poll_nb`, `poll_nb_each`, `poll_batch` and `poll_batch_nb` now raise `RdkafkaError` with `details` populated (`{topic:, partition:, offset:}`) when a message contains an error, consistent with `poll`.
41
57
 
42
58
  ## 0.27.0 (2026-05-08)
43
59
  - [Feature] Add `Consumer#poll_batch(timeout_ms, max_items:)` and `Consumer#poll_batch_nb(timeout_ms, max_items:)` for batch message polling via `rd_kafka_consume_batch_queue` (from upstream).
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Karafka-Rdkafka
2
2
 
3
- [![Build Status](https://github.com/karafka/karafka-rdkafka/actions/workflows/ci_linux_ubuntu_x86_64_gnu.yml/badge.svg)](https://github.com/karafka/karafka-rdkafka/actions/workflows/ci_linux_x86_64_gnu.yml)
3
+ [![Build Status](https://github.com/karafka/karafka-rdkafka/actions/workflows/ci_linux_ubuntu_x86_64_gnu.yml/badge.svg)](https://github.com/karafka/karafka-rdkafka/actions/workflows/ci_linux_ubuntu_x86_64_gnu.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/karafka-rdkafka.svg)](https://badge.fury.io/rb/karafka-rdkafka)
5
5
  [![Join the chat at https://slack.karafka.io](https://raw.githubusercontent.com/karafka/misc/master/slack.svg)](https://slack.karafka.io)
6
6
 
@@ -61,14 +61,14 @@ Contributions should generally be made to the upstream [rdkafka-ruby repository]
61
61
 
62
62
  ## Versions
63
63
 
64
- | rdkafka-ruby | librdkafka | patches |
64
+ | karafka-rdkafka | librdkafka | patches |
65
65
  |-|-|-|
66
66
  | 0.28.x (2026-07-12) | 2.14.2 (2026-06-03) | yes |
67
67
  | 0.27.x (2026-05-08) | 2.14.1 (2026-04-15) | yes |
68
68
  | 0.26.x (2026-04-11) | 2.14.0 (2026-04-01) | yes |
69
69
  | 0.25.x (2026-04-02) | 2.13.2 (2026-03-02) | yes |
70
70
  | 0.24.x (2026-02-25) | 2.13.0 (2026-01-05) | yes |
71
- | 0.23.x (2025-11-01) | 2.12.1 (2025-10-16) | yes |
71
+ | 0.23.x (2025-11-01) | 2.12.1 (2025-10-21) | yes |
72
72
  | 0.22.x (2025-09-26) | 2.11.1 (2025-08-18) | yes |
73
73
  | 0.21.x (2025-08-18) | 2.11.0 (2025-07-03) | yes |
74
74
  | 0.20.x (2025-07-17) | 2.8.0 (2025-01-07) | yes |
data/ext/librdkafka.so CHANGED
Binary file
@@ -4,7 +4,8 @@ module Rdkafka
4
4
  class Admin
5
5
  # Report for create ACL operation result
6
6
  class CreateAclReport
7
- # Upon successful creation of Acl RD_KAFKA_RESP_ERR_NO_ERROR - 0 is returned as rdkafka_response
7
+ # Upon successful creation of Acl RD_KAFKA_RESP_ERR_NO_ERROR - 0 is returned as
8
+ # rdkafka_response
8
9
  # @return [Integer]
9
10
  attr_reader :rdkafka_response
10
11
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ class Admin
5
+ # Handle for delete records operation
6
+ class DeleteRecordsHandle < AbstractHandle
7
+ layout :pending, :bool,
8
+ :response, :int
9
+
10
+ # @return [String] the name of the operation
11
+ def operation_name
12
+ "delete records"
13
+ end
14
+
15
+ # @return [DeleteRecordsReport] report prepared by the background event callback, with the
16
+ # post-deletion low-watermark offsets (or per-partition errors)
17
+ def create_result
18
+ prepared_result
19
+ end
20
+
21
+ # Raises an error if the operation failed
22
+ # @raise [RdkafkaError]
23
+ def raise_error
24
+ raise RdkafkaError.new(
25
+ self[:response],
26
+ broker_message: broker_message
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ class Admin
5
+ # Report for delete records operation result
6
+ class DeleteRecordsReport
7
+ # Per-partition results. Each partition's `offset` is the post-deletion low-watermark (the
8
+ # smallest available offset of all live replicas) and its `err` carries the per-partition
9
+ # error code, if deletion failed for that partition.
10
+ # @return [Rdkafka::Consumer::TopicPartitionList]
11
+ attr_reader :offsets
12
+
13
+ # @param result_ptr [FFI::Pointer] pointer to the `rd_kafka_DeleteRecords_result_t`
14
+ def initialize(result_ptr)
15
+ @offsets = Rdkafka::Consumer::TopicPartitionList.new
16
+
17
+ return if result_ptr.null?
18
+
19
+ native_tpl = Bindings.rd_kafka_DeleteRecords_result_offsets(result_ptr)
20
+
21
+ @offsets = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(native_tpl)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,7 +4,8 @@ module Rdkafka
4
4
  class Admin
5
5
  # Report for describe ACL operation result
6
6
  class DescribeAclReport
7
- # acls that exists in the cluster for the resource_type, resource_name and pattern_type filters provided in the request.
7
+ # acls that exists in the cluster for the resource_type, resource_name and pattern_type
8
+ # filters provided in the request.
8
9
  # @return [Rdkafka::Bindings::AclBindingResult] array of matching acls.
9
10
  attr_reader :acls
10
11
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ class Admin
5
+ # Handle for list consumer groups operation
6
+ class ListConsumerGroupsHandle < AbstractHandle
7
+ layout :pending, :bool,
8
+ :response, :int
9
+
10
+ # @return [String] the name of the operation
11
+ def operation_name
12
+ "list consumer groups"
13
+ end
14
+
15
+ # @return [ListConsumerGroupsReport] report prepared by the background event callback, with
16
+ # the listed consumer groups.
17
+ def create_result
18
+ prepared_result
19
+ end
20
+
21
+ # Raises an error if the operation failed
22
+ # @raise [RdkafkaError]
23
+ def raise_error
24
+ raise RdkafkaError.new(
25
+ self[:response],
26
+ broker_message: broker_message
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ class Admin
5
+ # Report for list consumer groups operation result
6
+ class ListConsumerGroupsReport
7
+ # Consumer groups listed cluster-wide. Each entry is a hash with:
8
+ # - `:group_id` [String] the consumer group id
9
+ # - `:is_simple_consumer_group` [Boolean] `true` for a "simple" consumer group - one that
10
+ # assigns partitions manually (via `assign`) and uses Kafka only for offset storage,
11
+ # rather than joining the group-management protocol and letting Kafka assign partitions
12
+ # and rebalance automatically (`subscribe`). Simple groups have no members from the
13
+ # broker's point of view, so they never rebalance.
14
+ # - `:state` [Integer] the group state as a `Bindings::RD_KAFKA_CONSUMER_GROUP_STATE_*`
15
+ # code, one of: `RD_KAFKA_CONSUMER_GROUP_STATE_UNKNOWN`,
16
+ # `RD_KAFKA_CONSUMER_GROUP_STATE_PREPARING_REBALANCE`,
17
+ # `RD_KAFKA_CONSUMER_GROUP_STATE_COMPLETING_REBALANCE`,
18
+ # `RD_KAFKA_CONSUMER_GROUP_STATE_STABLE`, `RD_KAFKA_CONSUMER_GROUP_STATE_DEAD`,
19
+ # `RD_KAFKA_CONSUMER_GROUP_STATE_EMPTY`
20
+ # - `:state_name` [String] human-readable name of that state (e.g. `"Stable"`, `"Empty"`)
21
+ # @return [Array<Hash>]
22
+ attr_reader :groups
23
+
24
+ # Per-broker errors reported alongside the (partial) group listing. `ListConsumerGroups`
25
+ # fans out to every broker and returns valid groups and errors separately, so a broker
26
+ # being unreachable does not discard the groups the reachable brokers returned.
27
+ # @return [Array<RdkafkaError>]
28
+ attr_reader :errors
29
+
30
+ # @param result_ptr [FFI::Pointer] pointer to the `rd_kafka_ListConsumerGroups_result_t`
31
+ def initialize(result_ptr)
32
+ @groups = []
33
+ @errors = []
34
+
35
+ return if result_ptr.null?
36
+
37
+ extract_groups(result_ptr)
38
+ extract_errors(result_ptr)
39
+ end
40
+
41
+ private
42
+
43
+ # @param result_ptr [FFI::Pointer] pointer to the result
44
+ def extract_groups(result_ptr)
45
+ count_ptr = FFI::MemoryPointer.new(:size_t)
46
+ array_ptr = Bindings.rd_kafka_ListConsumerGroups_result_valid(result_ptr, count_ptr)
47
+
48
+ return if array_ptr.null?
49
+
50
+ array_ptr.read_array_of_pointer(count_ptr.read(:size_t)).each do |listing_ptr|
51
+ state = Bindings.rd_kafka_ConsumerGroupListing_state(listing_ptr)
52
+ group_id_ptr = Bindings.rd_kafka_ConsumerGroupListing_group_id(listing_ptr)
53
+ state_name_ptr = Bindings.rd_kafka_consumer_group_state_name(state)
54
+
55
+ @groups << {
56
+ group_id: group_id_ptr.null? ? nil : group_id_ptr.read_string,
57
+ is_simple_consumer_group:
58
+ Bindings.rd_kafka_ConsumerGroupListing_is_simple_consumer_group(listing_ptr) != 0,
59
+ state: state,
60
+ state_name: state_name_ptr.null? ? nil : state_name_ptr.read_string
61
+ }
62
+ end
63
+ end
64
+
65
+ # @param result_ptr [FFI::Pointer] pointer to the result
66
+ def extract_errors(result_ptr)
67
+ count_ptr = FFI::MemoryPointer.new(:size_t)
68
+ array_ptr = Bindings.rd_kafka_ListConsumerGroups_result_errors(result_ptr, count_ptr)
69
+
70
+ return if array_ptr.null?
71
+
72
+ array_ptr.read_array_of_pointer(count_ptr.read(:size_t)).each do |error_ptr|
73
+ string_ptr = Bindings.rd_kafka_error_string(error_ptr)
74
+
75
+ @errors << RdkafkaError.new(
76
+ Bindings.rd_kafka_error_code(error_ptr),
77
+ broker_message: string_ptr.null? ? nil : string_ptr.read_string
78
+ )
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end