Skip to content

binding-kafka: add OffsetDelete (v0) wire codecs to the public api package #3173

Closed

Description

@jfallows

Problem

binding-kafka exposes typed wire codecs for a set of Kafka request/response pairs in its public io.aklivity.zilla.runtime.binding.kafka.api package (for example KafkaFindCoordinatorRequest with a Generator, KafkaFindCoordinatorResponseV3FW, KafkaListOffsetsRequest, KafkaListOffsetsResponseV6FW, KafkaOffsetFetchRequest, KafkaOffsetFetchResponseV6FW). They are used together with the raw API request/response streams (KafkaApiRequestBeginEx / KafkaApiResponseBeginEx), where the caller encodes and decodes the Kafka wire frames itself.

There is no codec for OffsetDelete (API key 47), the Kafka request that removes the committed offsets of a consumer group for given topic partitions. In this repository OffsetDelete appears only as a value of the event KafkaApiKey enum. Committing a chosen offset is not a substitute: it needs a target offset per partition and there is no sentinel meaning "no committed offset".

Expected

  • KafkaOffsetDeleteRequest (with sizeof, a Source and a Generator) and KafkaOffsetDeleteResponse / KafkaOffsetDeleteResponseV0FW, in the same package and with the same structure and naming as the FindCoordinator and ListOffsets codecs.
  • OffsetDelete version 0 only, laid out per the Kafka protocol definition (OffsetDeleteRequest.json / OffsetDeleteResponse.json): version 0 is not a flexible version, so strings carry an int16 length, arrays an int32 count and there are no tagged fields; the request uses header v1 and the response header v0.
  • The response codec exposes the top-level error code, the throttle time, and the per-partition error codes.
  • Unit tests in the style of KafkaFindCoordinatorRequestTest / KafkaFindCoordinatorResponseV3FWTest, written first.

Out of scope

  • No change to kafka.idl, no new application stream type, no client factory.
  • DeleteGroups (API key 42) is not covered: it is a separate request, and it is rejected by the broker for a group that has active members. It can be proposed separately.

Test plan (test-first)

Golden-byte unit tests for the request generator (generate, sizeof, count mismatch, buffer too small, unsupported version) and the response decoder (per-partition errors, top-level error). The tests are committed first and fail before the codec exists.

Activity

  1. jfallows commented on Nov 12, 2026

    @jfallows
    ContributorAuthor

    Design

    Pattern mirrored

    The newer one-shot admin streams under KafkaApi.REQUEST / RESPONSE (nested sub-union keyed by Kafka api key), specifically KafkaClientDeleteTopicsFactory (KafkaDeleteTopicsRequestBeginEx / KafkaDeleteTopicsResponseBeginEx, routed by KafkaClientRequestFactory). Two things are taken from the legacy group streams, because DeleteTopics has no equivalent:

    • the coordinator is addressed by host / port in the begin extension, as KafkaOffsetFetchBeginEx and KafkaOffsetCommitBeginEx do (and the network side reads the proxy begin ex for that address);
    • a group-level error code that applies to the whole response becomes RESET with KafkaResetEx.error, as KafkaClientOffsetFetchFactory does through onDecodeResponseErrorCode and cleanupApplication.

    No cache client/server change and no KafkaClientFactory change: both new streams are REQUEST sub-kinds, so only KafkaClientRequestFactory registers them.

    Scope: both operations, as two sub-kinds

    OffsetDelete (47) and DeleteGroups (42) are different requests with different results, so each is its own REQUEST sub-kind and its own client factory, rather than one stream with a mode flag. The issue asks for "the committed offsets ... or the group", so both are covered. The two are independent; if preferred the second can follow in a separate change.

    kafka.idl additions (specs/binding-kafka.spec/.../kafka.idl)

    • KafkaApi: add OFFSET_DELETE (47) and DELETE_GROUPS (42).
    • Request begin extensions (new case 47 / case 42 in KafkaRequestBeginEx):
      • KafkaOffsetDeleteRequestBeginEx { string16 groupId; string16 host; int32 port; KafkaOffsetDeleteTopic[] topics; } with KafkaOffsetDeleteTopic { string16 name; KafkaTopicPartition[] partitions; }
      • KafkaDeleteGroupsRequestBeginEx { string16 host; int32 port; string16[] groupIds; }
    • Response begin extensions (new cases in KafkaResponseBeginEx), carrying the whole result as DeleteTopics does:
      • KafkaOffsetDeleteResponseBeginEx { int32 throttle; KafkaOffsetDeleteTopicStatus[] topics; } with KafkaOffsetDeleteTopicStatus { string16 name; KafkaOffsetDeletePartitionStatus[] partitions; } and KafkaOffsetDeletePartitionStatus { int32 partitionId; int16 error; }
      • KafkaDeleteGroupsResponseBeginEx { int32 throttle; KafkaDeleteGroupStatus[] groups; } with KafkaDeleteGroupStatus { string16 groupId; int16 error; }
    • No data and no flush extension, and no new reset struct (KafkaResetEx.error already exists).
    • protocol.idl (runtime wire codecs): new codec.offset_delete and codec.delete_groups scopes, following codec.delete_topics.
    • KafkaFunctions (spec project): builders and matchers for the four extensions, plus KafkaFunctionsTest cases.

    Stream lifecycle (identical to DeleteTopics)

    1. Application BEGIN with the request extension. Client opens the network side, sends the request (after SASL handshake/authenticate when configured), grants a zero-credit WINDOW.
    2. Application DATA is not allowed (half-duplex): cleanup, as DeleteTopics does.
    3. Response decoded; client sends the reply BEGIN carrying the response extension, then END when the network ends.
    4. Application ABORT / RESET propagate to the network side.

    Error mapping

    Condition Result
    Per-partition error in OffsetDelete (e.g. GROUP_SUBSCRIBED_TO_TOPIC 86, UNKNOWN_TOPIC_OR_PARTITION 3) reply BEGIN partitions[].error, then END (like DeleteTopics per-item status)
    Per-group error in DeleteGroups (e.g. NON_EMPTY_GROUP 68, GROUP_ID_NOT_FOUND 69, NOT_COORDINATOR 16) reply BEGIN groups[].error, then END
    Group-level (top-level) error in OffsetDelete (e.g. GROUP_AUTHORIZATION_FAILED 30, COORDINATOR_NOT_AVAILABLE 15, GROUP_ID_NOT_FOUND 69, INVALID_GROUP_ID 24) RESET with KafkaResetEx.error = code, then ABORT, plus the existing onDecodeResponseErrorCode event (the OffsetFetch behavior)
    SASL failure, unsupported version, transport failure, malformed response RESET with KafkaResetEx.error, then ABORT (existing cleanupApplication / decodeReject behavior)

    Group with active members

    Not handled specially in the client: the broker decides and the result is reported, never retried or worked around. DeleteGroups on a non-empty group yields NON_EMPTY_GROUP in that group's status; OffsetDelete for a topic the active group is subscribed to yields GROUP_SUBSCRIBED_TO_TOPIC for those partitions, while partitions the group is not subscribed to are deleted in the same request. Both are therefore visible per item to the caller.

    Kafka protocol versions

    • OffsetDelete: v0, the only version defined, non-flexible.
    • DeleteGroups: v2, the highest version defined and the first flexible one (compact strings, tagged fields), the same encoding style as DeleteTopics v6. Older versions (v0, v1) are not supported.
    • A single version is hard-wired per api, as in KafkaClientDeleteTopicsFactory (DELETE_TOPICS_API_VERSION = 6); a broker that does not support it answers with an error that becomes a RESET. I will check the exact layouts and versions against https://kafka.apache.org/protocol before writing the scripts.

    Test plan

    Paired client.rpt / server.rpt under streams/application/offset.delete/* and delete.groups/*, and streams/network/offset.delete.v0/* and delete.groups.v2/* (each with a SASL variant only if DeleteTopics has one for the same scenario): success, per-partition error / per-group error (active members), group-level error (RESET), and a rejected request. Spec ITs per side (ApplicationIT-style classes beside the neighbours, OffsetDeleteIT, DeleteGroupsIT) and the matching runtime ITs in binding-kafka.


    Generated by Claude Code

  2. changed the title [-]binding-kafka: delete the committed offsets of a consumer group[/-] [+]binding-kafka: add OffsetDelete (v0) wire codecs to the public api package[/+] on Nov 12, 2026
  3. jfallows commented on Nov 12, 2026

    @jfallows
    ContributorAuthor

    Revised design (supersedes the earlier design comment)

    The earlier proposal (new REQUEST/RESPONSE sub-kinds in kafka.idl with dedicated client factories) is withdrawn. The module's direction is separate per-API handling over the raw API streams, with the Kafka wire frames encoded and decoded by typed codecs in the public api package, so OffsetDelete follows that. The issue title and body are rewritten accordingly.

    Mirrored

    • KafkaFindCoordinatorRequest / KafkaFindCoordinatorResponse / KafkaFindCoordinatorResponseV3FW for naming, the sizeof + Generator shape, and the hand-crafted response view over generated protocol.idl flyweights.
    • KafkaListOffsetsRequest / KafkaListOffsetsResponse / KafkaListOffsetsResponseV6FW for the nested topic/partition shape: a Source + Generator + Topic builder for the request and a topic/partition cursor (hasNext() / next()) for the response, because OffsetDelete is also a topic-then-partition array.

    Classes (package io.aklivity.zilla.runtime.binding.kafka.api)

    • KafkaOffsetDeleteRequest: sizeof(Source, short) (version 0 only, otherwise UnsupportedOperationException), Source, Generator.generate(Source) and the incremental topics(groupId, count) / topic().name().partitions().partition() / build().
    • KafkaOffsetDeleteResponse: cursor interface with error() (top-level), throttleTimeMillis(), topicCount(), Topic and Partition (partitionIndex(), errorCode()).
    • KafkaOffsetDeleteResponseV0FW: the v0 decoder.
    • protocol.idl: new offset_delete codec scope (non-flexible: string16, int32 counts, no tagged fields).

    Protocol layout used (v0, from the Kafka protocol message definitions OffsetDeleteRequest.json / OffsetDeleteResponse.json)

    • Request: group_id STRING; topics ARRAY of { name STRING; partitions ARRAY of { partition_index INT32 } }.
    • Response: error_code INT16; throttle_time_ms INT32; topics ARRAY of { name STRING; partitions ARRAY of { partition_index INT32; error_code INT16 } }.
    • Version 1 (flexible) is marked unstable upstream, so only version 0 is supported.

    Tests

    KafkaOffsetDeleteRequestTest and KafkaOffsetDeleteResponseV0FWTest, golden bytes in the same style as the FindCoordinator and ListOffsets tests.


    Generated by Claude Code

  4. self-assigned this
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions