You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by "krishvishal (via GitHub)" <gi...@apache.org> on 2026/09/16 18:41:24 UTC

[PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

krishvishal opened a new pull request, #4205:
URL: https://github.com/apache/iggy/pull/4205

   `BRIDGE_MAPPING.md` is the last unchecked item in #3533 and is needed to design #3535 and #3536. The maintainer thread agreed on 16 September that each Kafka record should become one message in Iggy's native format. Four questions remain, with proposed defaults:
   
   1. Use an envelope for records Iggy cannot represent, or reject them with `MESSAGE_TOO_LARGE`? Default: envelope.
   2. Keep the `kafka.` prefix? `kafka.h.` uses 8 bytes of the 255-byte header-name limit. Default: keep it.
   3. Use a placeholder byte for tombstones, even though native consumers would see a byte the producer never sent? Default: keep it.
   4. Recompress on Fetch or return uncompressed records? Default: uncompressed.
   
   `IDEMPOTENCE.md` (#3545) allocates producer IDs but ignores sequence fields because a stock Java producer treats unsupported `InitProducerId` as fatal instead of falling back. `OFFSET_STORAGE.md` (#3540) uses Iggy's native consumer offsets, one per partition—an option missing from the A/B/C list. The diff also corrects two inaccurate claims in `SCOPE.md`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #4205:
URL: https://github.com/apache/iggy/pull/4205#issuecomment-5702988758

   ## [Codecov](https://app.codecov.io/gh/apache/iggy/pull/4205?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 61.16%. Comparing base ([`63362dc`](https://app.codecov.io/gh/apache/iggy/commit/63362dc5478c63fe006341fadff5dd5d9acb68c2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ffbbed3`](https://app.codecov.io/gh/apache/iggy/commit/ffbbed3ca2dd1d840dae4fcbc1d44dc0506797ed?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff              @@
   ##             master    #4205       +/-   ##
   =============================================
   - Coverage     87.48%   61.16%   -26.33%     
     Complexity     1575     1575               
   =============================================
     Files          1280     1280               
     Lines        223192   223192               
     Branches     186555   186555               
   =============================================
   - Hits         195267   136516    -58751     
   - Misses        23229    82051    +58822     
   + Partials       4696     4625       -71     
   ```
   
   | [Components](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [Rust Core](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.64% <ø> (-31.93%)` | :arrow_down: |
   | [Java SDK](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `68.68% <ø> (ø)` | |
   | [C# SDK](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.49% <ø> (ø)` | |
   | [Python SDK](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `90.97% <ø> (ø)` | |
   | [PHP SDK](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `85.67% <ø> (ø)` | |
   | [Node SDK](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `96.43% <ø> (ø)` | |
   | [Go SDK](https://app.codecov.io/gh/apache/iggy/pull/4205/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.05% <ø> (ø)` | |
   [see 495 files with indirect coverage changes](https://app.codecov.io/gh/apache/iggy/pull/4205/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031391734


##########
gateways/kafka/docs/OFFSET_STORAGE.md:
##########
@@ -0,0 +1,132 @@
+# Consumer offset storage
+
+Status: proposed. Answers [#3540](https://github.com/apache/iggy/issues/3540) and blocks
+[#3542](https://github.com/apache/iggy/issues/3542), OffsetCommit and OffsetFetch.
+
+## Decision
+
+Store Kafka group offsets as Iggy consumer offsets, one key per partition, under a consumer
+group whose name is derived from the Kafka group id.
+
+The issue lists three options. None of them is this one.
+
+| Option | Why not |
+| -------- | --------- |
+| A, an Iggy-backed `__consumer_offsets` topic | Rebuilds what Iggy already has. A compacted offset topic needs compaction, which Iggy does not have, so the gateway replays the whole topic at every startup |
+| B, a SQLite file on the gateway host | A second durability story, a second backup story, and offsets that do not survive moving the gateway |
+| C, in memory only | Fails the acceptance criterion in #3542, which is that offsets survive a restart |
+
+Iggy already stores a durable offset per consumer and per partition, replicated with the
+partition itself. Using it costs one call per partition on commit and one on fetch.
+
+## The key
+
+One Iggy consumer offset per Kafka `(group, topic, partition)`.
+
+- consumer kind: `ConsumerKind::ConsumerGroup`
+- consumer id: `Identifier::named("kafka.cg.<group>")`
+- stream and topic: whatever `TopicMapping` resolves the Kafka topic to
+- partition: the Kafka partition index, unchanged, because both sides number from 0
+
+The gateway calls `create_consumer_group(stream, topic, "kafka.cg.<group>")` before the first
+commit for a group on a topic. If the group does not resolve in metadata, the server rejects the
+offset write. The group has to exist first. The gateway never joins the group. Offsets are
+readable by any client, member or not.
+
+### Why the group kind and not a named consumer
+
+`ConsumerKind::Consumer` with a name looks simpler, because it needs no registration call. It is
+not. The server hashes a named consumer id to a `u32` with `XxHash32`
+(`core/server/src/dispatch/partition.rs:916`), and that hash is the offset key. Two different
+group names can collide and silently share one offset.
+
+A consumer group name resolves through metadata to a monotonic id instead. No hash, no
+collision, and `get_consumer_groups(stream, topic)` lists what exists.
+
+### Why the prefix
+
+`kafka.cg.` keeps a Kafka group called `orders` off the key that a native Iggy consumer group
+called `orders` uses. Without it the two share an offset and each one moves the other.
+
+The prefix does not make the offsets safe to poll with. That is the next section.
+
+## What is stored
+
+The Kafka committed offset, verbatim, with no conversion.
+
+The two systems mean different things by the number. Kafka commits the next offset to read.
+Iggy stores the last offset processed, and `PollingKind::Next` resumes at the stored value plus
+one (`core/partitions/src/iggy_partition.rs:3835`). A Kafka offset stored in an Iggy key is
+therefore one greater than Iggy's own convention for that key.
+

Review Comment:
   How is Kafka s OffsetCommit offset -1 (forget commit) mapped in Iggy?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "krishvishal (via GitHub)" <gi...@apache.org>.
krishvishal commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4032967369


##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |

Review Comment:
   Kafka is milliseconds, `origin_timestamp` is microseconds (`iggy_message.rs:191`), so produce multiplies by 1000 and fetch divides. Now in the field mapping, along with the -1 case.



##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |
+| record offset | partition offset, assigned by Iggy |
+| partition index | partition index, both 0-based |
+| topic | stream and topic per `TopicMapping` |
+
+Fetch reverses it. A message with no `kafka.*` headers is a message an Iggy client wrote, and
+encodes as a Kafka record with a null key, its Iggy user headers as Kafka headers, and
+`origin_timestamp` as the record timestamp (falling back to the server-assigned `timestamp`

Review Comment:
   Same factor both ways. The only asymmetry is an iggy-written message losing sub-millisecond precision, since kafka has nowhere to put it.



##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |
+| record offset | partition offset, assigned by Iggy |
+| partition index | partition index, both 0-based |
+| topic | stream and topic per `TopicMapping` |
+
+Fetch reverses it. A message with no `kafka.*` headers is a message an Iggy client wrote, and
+encodes as a Kafka record with a null key, its Iggy user headers as Kafka headers, and
+`origin_timestamp` as the record timestamp (falling back to the server-assigned `timestamp`
+when the origin timestamp is zero). Iggy header kinds other than `Raw` and `String` are emitted
+as their raw value bytes.
+
+## Records Iggy cannot hold natively
+
+Iggy rejects an empty payload (`core/common/src/types/message/iggy_message.rs:169`), caps a
+user header value at 255 bytes (`core/common/src/types/message/user_headers.rs:631`), keys
+headers in a `BTreeMap` so a name cannot repeat, and caps all user headers of a message at
+100 KB (`MAX_USER_HEADERS_SIZE`). Kafka allows all of the shapes those rules exclude, so two
+mechanisms cover them.
+
+### Null and empty values
+
+A record with a null value (a tombstone) or a zero-length value is stored with a single `0x00`
+byte payload and a `kafka.value` header holding `null` or `empty`. Fetch reads that header and
+restores the original, discarding the placeholder byte.
+
+This keeps tombstones on the fast path rather than pushing them into the fallback, because they
+are ordinary traffic on compacted Kafka topics. Iggy has no compaction, so a tombstone is stored
+and served like any other record and nothing acts on it.
+
+### Everything else: the envelope fallback
+
+A record takes the fallback when any of these hold:
+
+- the key is longer than 255 bytes
+- a header name, prefixed with `kafka.h.`, is longer than 255 bytes
+- a header value is null, empty, or longer than 255 bytes
+- two headers share a name
+- the headers together would exceed the 100 KB user-header budget

Review Comment:
   Not our number, it is `MAX_USER_HEADERS_SIZE` (`iggy_message.rs:58`), fixed with no knob and no rationale recorded next to it. Reworded as inherited, and it works out to ~350 headers at the value cap, so the key-length rule is what actually trips.



##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |
+| record offset | partition offset, assigned by Iggy |
+| partition index | partition index, both 0-based |
+| topic | stream and topic per `TopicMapping` |
+
+Fetch reverses it. A message with no `kafka.*` headers is a message an Iggy client wrote, and
+encodes as a Kafka record with a null key, its Iggy user headers as Kafka headers, and
+`origin_timestamp` as the record timestamp (falling back to the server-assigned `timestamp`
+when the origin timestamp is zero). Iggy header kinds other than `Raw` and `String` are emitted
+as their raw value bytes.
+
+## Records Iggy cannot hold natively
+
+Iggy rejects an empty payload (`core/common/src/types/message/iggy_message.rs:169`), caps a
+user header value at 255 bytes (`core/common/src/types/message/user_headers.rs:631`), keys
+headers in a `BTreeMap` so a name cannot repeat, and caps all user headers of a message at
+100 KB (`MAX_USER_HEADERS_SIZE`). Kafka allows all of the shapes those rules exclude, so two
+mechanisms cover them.
+
+### Null and empty values
+
+A record with a null value (a tombstone) or a zero-length value is stored with a single `0x00`
+byte payload and a `kafka.value` header holding `null` or `empty`. Fetch reads that header and
+restores the original, discarding the placeholder byte.
+
+This keeps tombstones on the fast path rather than pushing them into the fallback, because they
+are ordinary traffic on compacted Kafka topics. Iggy has no compaction, so a tombstone is stored
+and served like any other record and nothing acts on it.
+
+### Everything else: the envelope fallback
+
+A record takes the fallback when any of these hold:
+
+- the key is longer than 255 bytes
+- a header name, prefixed with `kafka.h.`, is longer than 255 bytes
+- a header value is null, empty, or longer than 255 bytes
+- two headers share a name
+- the headers together would exceed the 100 KB user-header budget
+
+Such a record is stored with a `kafka.envelope` header carrying the format version, and the

Review Comment:
   `kafka_protocol` decodes to a `Record` and keeps no raw slice, so there was never a verbatim body to store. Layout is pinned in the doc now, 13 bytes fixed plus 9 per header.



##########
gateways/kafka/docs/IDEMPOTENCE.md:
##########
@@ -0,0 +1,92 @@
+# InitProducerId and idempotent producers
+
+Status: proposed. Answers the open half of
+[#3545](https://github.com/apache/iggy/issues/3545) and gates the Phase 1 end-to-end test
+([#3539](https://github.com/apache/iggy/issues/3539)), which drives
+`kafka-console-producer.sh`.
+
+## The problem
+
+A stock Java producer sets `enable.idempotence=true` without being asked. That default arrived
+in Kafka 3.0 and took effect from 3.0.1, 3.1.1 and 3.2.0, where a bug that suppressed it was
+fixed. `kafka-console-producer.sh` leaves it on.
+
+An idempotent producer sends InitProducerId (key 22) before its first record. The gateway does
+not list key 22, so ApiVersions does not advertise it, and the producer raises
+`UnsupportedVersionException`. That exception is fatal.
+`TransactionManager.maybeTransitionToErrorState` tests it above the `isTransactional()` branch.
+The producer therefore enters a fatal error state instead of dropping back to weaker semantics.
+It fails at startup, before it sends a record.
+
+The gateway's stated purpose is that a Kafka user swaps the broker and changes no application
+code. A broker that the default producer cannot start against does not meet it.
+
+## Options
+
+| Option | Cost | What a stock producer does |
+| -------- | ------ | ---------------------------- |
+| Stub with `UNSUPPORTED_VERSION` | none | fails at startup unless the user sets `enable.idempotence=false` |
+| Allocate only | about a day | works untouched, at-least-once delivery |
+| Real deduplication | large | works untouched, exactly once per partition, single gateway instance only |
+
+Real deduplication means tracking a sequence number per producer and per partition, and
+rejecting a duplicate or a gap. It is correct only while one gateway instance sees every write
+from a producer, so it cannot be decided before the multi-instance question is.
+
+## Decision
+
+Allocate only.
+
+Rejecting the stock producer to avoid implementing deduplication trades the one requirement the
+maintainers named against a guarantee Iggy does not offer today anyway. Allocating costs about
+a day and keeps delivery exactly where it already is.
+
+## Behavior
+
+Add key 22 to `SUPPORTED_RANGES` in `src/protocol/api.rs` and advertise it through ApiVersions.
+Without both, the producer never sends the request. `kafka-protocol` 0.18 carries the schemas,
+request v0 to v5 and response v0 to v6, flexible from v2.
+
+InitProducerId with no `transactional_id`:
+
+- allocate the next producer id, return it with epoch 0 and error code 0
+- draw ids from a counter seeded per gateway instance, so two instances never hand out the same
+  id. Nothing reads the id today. Seeding it now is what stops a later deduplication layer from
+  being born broken
+
+InitProducerId with a `transactional_id`:
+
+- answer `UNSUPPORTED_VERSION` (35), unchanged. Transactions stay out of scope, and so do

Review Comment:
   35 because INVALID_REQUEST is not in `maybeTransitionToErrorState`'s fatal set, so a transactional producer goes abortable and is told to retry something that can never work. COORDINATOR_NOT_AVAILABLE is worse, it is retriable.



##########
gateways/kafka/docs/OFFSET_STORAGE.md:
##########
@@ -0,0 +1,132 @@
+# Consumer offset storage
+
+Status: proposed. Answers [#3540](https://github.com/apache/iggy/issues/3540) and blocks
+[#3542](https://github.com/apache/iggy/issues/3542), OffsetCommit and OffsetFetch.
+
+## Decision
+
+Store Kafka group offsets as Iggy consumer offsets, one key per partition, under a consumer
+group whose name is derived from the Kafka group id.
+
+The issue lists three options. None of them is this one.
+
+| Option | Why not |
+| -------- | --------- |
+| A, an Iggy-backed `__consumer_offsets` topic | Rebuilds what Iggy already has. A compacted offset topic needs compaction, which Iggy does not have, so the gateway replays the whole topic at every startup |
+| B, a SQLite file on the gateway host | A second durability story, a second backup story, and offsets that do not survive moving the gateway |
+| C, in memory only | Fails the acceptance criterion in #3542, which is that offsets survive a restart |
+
+Iggy already stores a durable offset per consumer and per partition, replicated with the
+partition itself. Using it costs one call per partition on commit and one on fetch.
+
+## The key
+
+One Iggy consumer offset per Kafka `(group, topic, partition)`.
+
+- consumer kind: `ConsumerKind::ConsumerGroup`
+- consumer id: `Identifier::named("kafka.cg.<group>")`
+- stream and topic: whatever `TopicMapping` resolves the Kafka topic to
+- partition: the Kafka partition index, unchanged, because both sides number from 0
+
+The gateway calls `create_consumer_group(stream, topic, "kafka.cg.<group>")` before the first
+commit for a group on a topic. If the group does not resolve in metadata, the server rejects the
+offset write. The group has to exist first. The gateway never joins the group. Offsets are
+readable by any client, member or not.
+
+### Why the group kind and not a named consumer
+
+`ConsumerKind::Consumer` with a name looks simpler, because it needs no registration call. It is
+not. The server hashes a named consumer id to a `u32` with `XxHash32`
+(`core/server/src/dispatch/partition.rs:916`), and that hash is the offset key. Two different
+group names can collide and silently share one offset.
+
+A consumer group name resolves through metadata to a monotonic id instead. No hash, no
+collision, and `get_consumer_groups(stream, topic)` lists what exists.
+
+### Why the prefix
+
+`kafka.cg.` keeps a Kafka group called `orders` off the key that a native Iggy consumer group
+called `orders` uses. Without it the two share an offset and each one moves the other.
+
+The prefix does not make the offsets safe to poll with. That is the next section.
+
+## What is stored
+
+The Kafka committed offset, verbatim, with no conversion.
+
+The two systems mean different things by the number. Kafka commits the next offset to read.
+Iggy stores the last offset processed, and `PollingKind::Next` resumes at the stored value plus
+one (`core/partitions/src/iggy_partition.rs:3835`). A Kafka offset stored in an Iggy key is
+therefore one greater than Iggy's own convention for that key.
+

Review Comment:
   Kafka does not validate the sign, it stores -1 and hands it back. We cannot (u64), so -1 maps to `delete_consumer_offset` for the same observable result, with 3021 counted as success.



##########
gateways/kafka/docs/OFFSET_STORAGE.md:
##########
@@ -0,0 +1,132 @@
+# Consumer offset storage
+
+Status: proposed. Answers [#3540](https://github.com/apache/iggy/issues/3540) and blocks
+[#3542](https://github.com/apache/iggy/issues/3542), OffsetCommit and OffsetFetch.
+
+## Decision
+
+Store Kafka group offsets as Iggy consumer offsets, one key per partition, under a consumer
+group whose name is derived from the Kafka group id.
+
+The issue lists three options. None of them is this one.
+
+| Option | Why not |
+| -------- | --------- |
+| A, an Iggy-backed `__consumer_offsets` topic | Rebuilds what Iggy already has. A compacted offset topic needs compaction, which Iggy does not have, so the gateway replays the whole topic at every startup |
+| B, a SQLite file on the gateway host | A second durability story, a second backup story, and offsets that do not survive moving the gateway |
+| C, in memory only | Fails the acceptance criterion in #3542, which is that offsets survive a restart |
+
+Iggy already stores a durable offset per consumer and per partition, replicated with the
+partition itself. Using it costs one call per partition on commit and one on fetch.
+
+## The key
+
+One Iggy consumer offset per Kafka `(group, topic, partition)`.
+
+- consumer kind: `ConsumerKind::ConsumerGroup`
+- consumer id: `Identifier::named("kafka.cg.<group>")`
+- stream and topic: whatever `TopicMapping` resolves the Kafka topic to
+- partition: the Kafka partition index, unchanged, because both sides number from 0
+
+The gateway calls `create_consumer_group(stream, topic, "kafka.cg.<group>")` before the first
+commit for a group on a topic. If the group does not resolve in metadata, the server rejects the
+offset write. The group has to exist first. The gateway never joins the group. Offsets are
+readable by any client, member or not.
+
+### Why the group kind and not a named consumer
+
+`ConsumerKind::Consumer` with a name looks simpler, because it needs no registration call. It is
+not. The server hashes a named consumer id to a `u32` with `XxHash32`
+(`core/server/src/dispatch/partition.rs:916`), and that hash is the offset key. Two different
+group names can collide and silently share one offset.
+
+A consumer group name resolves through metadata to a monotonic id instead. No hash, no
+collision, and `get_consumer_groups(stream, topic)` lists what exists.
+
+### Why the prefix
+
+`kafka.cg.` keeps a Kafka group called `orders` off the key that a native Iggy consumer group
+called `orders` uses. Without it the two share an offset and each one moves the other.
+
+The prefix does not make the offsets safe to poll with. That is the next section.
+
+## What is stored
+
+The Kafka committed offset, verbatim, with no conversion.
+
+The two systems mean different things by the number. Kafka commits the next offset to read.
+Iggy stores the last offset processed, and `PollingKind::Next` resumes at the stored value plus
+one (`core/partitions/src/iggy_partition.rs:3835`). A Kafka offset stored in an Iggy key is
+therefore one greater than Iggy's own convention for that key.
+
+This is inert because the gateway never polls that way. Fetch always polls with an explicit
+offset, `PollingKind::Offset`, taken from the Kafka request. Nothing in the gateway reads the
+stored value to decide where to resume. It is returned to the client on OffsetFetch and
+otherwise untouched.
+
+The rule this creates: no code path polls a `kafka.cg.*` key with `PollingKind::Next`. Doing so
+skips one record per partition. The prefix is what keeps a native Iggy consumer from doing it by
+accident.
+
+Converting on write instead, and storing the Kafka offset minus one, breaks at offset 0. It also
+makes an empty commit look the same as a commit of the first record. Storing verbatim is the
+smaller problem.
+
+## OffsetFetch with no topics named
+
+OffsetFetch v2 and later let a client pass a null topic list, which asks for every offset the
+group holds. `kafka-consumer-groups.sh --describe` does this.
+
+Iggy has no lookup by consumer. Offsets are read one partition at a time
+(`core/common/src/traits/consumer_offset_client.rs:41`). The gateway answers by enumerating the
+topics in the mapped stream and querying each partition of each one.
+
+That is one round trip per partition on an admin call. The cost is bounded by the topic and
+partition count of one stream. This is an admin path and not a data path, so the cost is
+acceptable. It is written here so nobody discovers it in a test.
+
+## What is dropped
+
+Kafka lets a client attach a metadata string to a commit. Iggy stores a number and nothing else.
+The string is dropped on commit, and OffsetFetch returns an empty string.
+
+`committed_leader_epoch` is dropped the same way. The gateway reports `-1`.
+
+## Limits
+
+A partition admits a bounded number of distinct offset keys per consumer kind. The default is

Review Comment:
   Done, `partition.consumer_offsets_max` is in the README with the 4096 default and the 262144 ceiling. There is no kafka code for the condition, so it stays UNKNOWN_SERVER_ERROR with the real iggy error logged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031259302


##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |
+| record offset | partition offset, assigned by Iggy |
+| partition index | partition index, both 0-based |
+| topic | stream and topic per `TopicMapping` |
+
+Fetch reverses it. A message with no `kafka.*` headers is a message an Iggy client wrote, and
+encodes as a Kafka record with a null key, its Iggy user headers as Kafka headers, and
+`origin_timestamp` as the record timestamp (falling back to the server-assigned `timestamp`

Review Comment:
   Refer earlier comment while decoding



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "numinnex (via GitHub)" <gi...@apache.org>.
numinnex commented on PR #4205:
URL: https://github.com/apache/iggy/pull/4205#issuecomment-5711210700

   A quick primer on the status quo is needed here, because it changes what this document should aim at.
   
   We never implemented Kafka's producer id and sequence machinery and do not intend to. What we do have, landed and on by default, is deduplication on the partition plane keyed on `(client_id, user_id, request)`, where the client id is a `u128` the client itself generates. Each partition group holds a per-client watermark with a 128-deep committed window below it, sized by `[partition] dedup_clients_max` at 4096 per group. Retried produces are what it exists to absorb, and the shape is nearer Kafka's than it looks: a producer id with a per-partition sequence maps onto a session id with a request id, both per partition, and our window is deeper than the five batches a Kafka producer keeps in flight.
   
   What breaks the mapping is which hop each side protects. Ours covers gateway to Iggy, Kafka's covers producer to gateway. A retrying producer sends a fresh Produce request, the gateway turns it into a fresh Iggy send carrying a fresh request id, and nothing recognises the replay. Closing that means deriving both halves of our key from the Kafka request instead of letting the SDK mint them, session id from the producer id and request id from the base sequence. `ConsensusSession::with_client_id` is public, but `TcpClient` builds its session at `tcp_client.rs:378` and `:583` with no way to pass one in, and `next_request_id` has no caller-supplied form, so the SDK needs work before the gateway can lean on any of this.
   
   Worth stating plainly what it buys, because it is not the whole contract. Retries stop duplicating, but an absorbed duplicate answers empty success with no base offset, so the retry reports an unknown one, and the watermark accepts anything above it without noticing a gap, which is why never sending 45 or 46 stays right.
   
   That makes your producer id layout more load-bearing rather than less, since the id is what a session key would derive from. Does the counter survive a restart? Transactions stay out permanently, and the unsupported-version answer is the one to keep.
   
   Four smaller things in the mapping doc: an empty record key has no path, since a zero-length key is not a null one and an empty header value is rejected at the same line cited for the 255-byte cap. The decompression bound is per batch where it needs to be per request, as one frame carries up to the 4096-element budget's worth of batches. Header order is lost to the `BTreeMap` and the doc never says so. OffsetFetch with a null topic list cannot reverse `TopicMapping::resolve`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031303057


##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |
+| record offset | partition offset, assigned by Iggy |
+| partition index | partition index, both 0-based |
+| topic | stream and topic per `TopicMapping` |
+
+Fetch reverses it. A message with no `kafka.*` headers is a message an Iggy client wrote, and
+encodes as a Kafka record with a null key, its Iggy user headers as Kafka headers, and
+`origin_timestamp` as the record timestamp (falling back to the server-assigned `timestamp`
+when the origin timestamp is zero). Iggy header kinds other than `Raw` and `String` are emitted
+as their raw value bytes.
+
+## Records Iggy cannot hold natively
+
+Iggy rejects an empty payload (`core/common/src/types/message/iggy_message.rs:169`), caps a
+user header value at 255 bytes (`core/common/src/types/message/user_headers.rs:631`), keys
+headers in a `BTreeMap` so a name cannot repeat, and caps all user headers of a message at
+100 KB (`MAX_USER_HEADERS_SIZE`). Kafka allows all of the shapes those rules exclude, so two
+mechanisms cover them.
+
+### Null and empty values
+
+A record with a null value (a tombstone) or a zero-length value is stored with a single `0x00`
+byte payload and a `kafka.value` header holding `null` or `empty`. Fetch reads that header and
+restores the original, discarding the placeholder byte.
+
+This keeps tombstones on the fast path rather than pushing them into the fallback, because they
+are ordinary traffic on compacted Kafka topics. Iggy has no compaction, so a tombstone is stored
+and served like any other record and nothing acts on it.
+
+### Everything else: the envelope fallback
+
+A record takes the fallback when any of these hold:
+
+- the key is longer than 255 bytes
+- a header name, prefixed with `kafka.h.`, is longer than 255 bytes
+- a header value is null, empty, or longer than 255 bytes
+- two headers share a name
+- the headers together would exceed the 100 KB user-header budget
+
+Such a record is stored with a `kafka.envelope` header carrying the format version, and the

Review Comment:
   Could the format/schema for such messages be decided upfront with bytes count.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031290720


##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |
+| record offset | partition offset, assigned by Iggy |
+| partition index | partition index, both 0-based |
+| topic | stream and topic per `TopicMapping` |
+
+Fetch reverses it. A message with no `kafka.*` headers is a message an Iggy client wrote, and
+encodes as a Kafka record with a null key, its Iggy user headers as Kafka headers, and
+`origin_timestamp` as the record timestamp (falling back to the server-assigned `timestamp`
+when the origin timestamp is zero). Iggy header kinds other than `Raw` and `String` are emitted
+as their raw value bytes.
+
+## Records Iggy cannot hold natively
+
+Iggy rejects an empty payload (`core/common/src/types/message/iggy_message.rs:169`), caps a
+user header value at 255 bytes (`core/common/src/types/message/user_headers.rs:631`), keys
+headers in a `BTreeMap` so a name cannot repeat, and caps all user headers of a message at
+100 KB (`MAX_USER_HEADERS_SIZE`). Kafka allows all of the shapes those rules exclude, so two
+mechanisms cover them.
+
+### Null and empty values
+
+A record with a null value (a tombstone) or a zero-length value is stored with a single `0x00`
+byte payload and a `kafka.value` header holding `null` or `empty`. Fetch reads that header and
+restores the original, discarding the placeholder byte.
+
+This keeps tombstones on the fast path rather than pushing them into the fallback, because they
+are ordinary traffic on compacted Kafka topics. Iggy has no compaction, so a tombstone is stored
+and served like any other record and nothing acts on it.
+
+### Everything else: the envelope fallback
+
+A record takes the fallback when any of these hold:
+
+- the key is longer than 255 bytes
+- a header name, prefixed with `kafka.h.`, is longer than 255 bytes
+- a header value is null, empty, or longer than 255 bytes
+- two headers share a name
+- the headers together would exceed the 100 KB user-header budget

Review Comment:
   Is 100Kb an optimal number or decided with any data point?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "krishvishal (via GitHub)" <gi...@apache.org>.
krishvishal merged PR #4205:
URL: https://github.com/apache/iggy/pull/4205


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031362487


##########
gateways/kafka/docs/IDEMPOTENCE.md:
##########
@@ -0,0 +1,92 @@
+# InitProducerId and idempotent producers
+
+Status: proposed. Answers the open half of
+[#3545](https://github.com/apache/iggy/issues/3545) and gates the Phase 1 end-to-end test
+([#3539](https://github.com/apache/iggy/issues/3539)), which drives
+`kafka-console-producer.sh`.
+
+## The problem
+
+A stock Java producer sets `enable.idempotence=true` without being asked. That default arrived
+in Kafka 3.0 and took effect from 3.0.1, 3.1.1 and 3.2.0, where a bug that suppressed it was
+fixed. `kafka-console-producer.sh` leaves it on.
+
+An idempotent producer sends InitProducerId (key 22) before its first record. The gateway does
+not list key 22, so ApiVersions does not advertise it, and the producer raises
+`UnsupportedVersionException`. That exception is fatal.
+`TransactionManager.maybeTransitionToErrorState` tests it above the `isTransactional()` branch.
+The producer therefore enters a fatal error state instead of dropping back to weaker semantics.
+It fails at startup, before it sends a record.
+
+The gateway's stated purpose is that a Kafka user swaps the broker and changes no application
+code. A broker that the default producer cannot start against does not meet it.
+
+## Options
+
+| Option | Cost | What a stock producer does |
+| -------- | ------ | ---------------------------- |
+| Stub with `UNSUPPORTED_VERSION` | none | fails at startup unless the user sets `enable.idempotence=false` |
+| Allocate only | about a day | works untouched, at-least-once delivery |
+| Real deduplication | large | works untouched, exactly once per partition, single gateway instance only |
+
+Real deduplication means tracking a sequence number per producer and per partition, and
+rejecting a duplicate or a gap. It is correct only while one gateway instance sees every write
+from a producer, so it cannot be decided before the multi-instance question is.
+
+## Decision
+
+Allocate only.
+
+Rejecting the stock producer to avoid implementing deduplication trades the one requirement the
+maintainers named against a guarantee Iggy does not offer today anyway. Allocating costs about
+a day and keeps delivery exactly where it already is.
+
+## Behavior
+
+Add key 22 to `SUPPORTED_RANGES` in `src/protocol/api.rs` and advertise it through ApiVersions.
+Without both, the producer never sends the request. `kafka-protocol` 0.18 carries the schemas,
+request v0 to v5 and response v0 to v6, flexible from v2.
+
+InitProducerId with no `transactional_id`:
+
+- allocate the next producer id, return it with epoch 0 and error code 0
+- draw ids from a counter seeded per gateway instance, so two instances never hand out the same

Review Comment:
   Good idea. Should just a counter value or should it be a instance id (something similar) + counter?



##########
gateways/kafka/docs/IDEMPOTENCE.md:
##########
@@ -0,0 +1,92 @@
+# InitProducerId and idempotent producers
+
+Status: proposed. Answers the open half of
+[#3545](https://github.com/apache/iggy/issues/3545) and gates the Phase 1 end-to-end test
+([#3539](https://github.com/apache/iggy/issues/3539)), which drives
+`kafka-console-producer.sh`.
+
+## The problem
+
+A stock Java producer sets `enable.idempotence=true` without being asked. That default arrived
+in Kafka 3.0 and took effect from 3.0.1, 3.1.1 and 3.2.0, where a bug that suppressed it was
+fixed. `kafka-console-producer.sh` leaves it on.
+
+An idempotent producer sends InitProducerId (key 22) before its first record. The gateway does
+not list key 22, so ApiVersions does not advertise it, and the producer raises
+`UnsupportedVersionException`. That exception is fatal.
+`TransactionManager.maybeTransitionToErrorState` tests it above the `isTransactional()` branch.
+The producer therefore enters a fatal error state instead of dropping back to weaker semantics.
+It fails at startup, before it sends a record.
+
+The gateway's stated purpose is that a Kafka user swaps the broker and changes no application
+code. A broker that the default producer cannot start against does not meet it.
+
+## Options
+
+| Option | Cost | What a stock producer does |
+| -------- | ------ | ---------------------------- |
+| Stub with `UNSUPPORTED_VERSION` | none | fails at startup unless the user sets `enable.idempotence=false` |
+| Allocate only | about a day | works untouched, at-least-once delivery |
+| Real deduplication | large | works untouched, exactly once per partition, single gateway instance only |
+
+Real deduplication means tracking a sequence number per producer and per partition, and
+rejecting a duplicate or a gap. It is correct only while one gateway instance sees every write
+from a producer, so it cannot be decided before the multi-instance question is.
+
+## Decision
+
+Allocate only.
+
+Rejecting the stock producer to avoid implementing deduplication trades the one requirement the
+maintainers named against a guarantee Iggy does not offer today anyway. Allocating costs about
+a day and keeps delivery exactly where it already is.
+
+## Behavior
+
+Add key 22 to `SUPPORTED_RANGES` in `src/protocol/api.rs` and advertise it through ApiVersions.
+Without both, the producer never sends the request. `kafka-protocol` 0.18 carries the schemas,
+request v0 to v5 and response v0 to v6, flexible from v2.
+
+InitProducerId with no `transactional_id`:
+
+- allocate the next producer id, return it with epoch 0 and error code 0
+- draw ids from a counter seeded per gateway instance, so two instances never hand out the same

Review Comment:
   Good idea. Should it be a just a counter value or should it be a instance id (something similar) + counter?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "gkoszyk (via GitHub)" <gi...@apache.org>.
gkoszyk commented on PR #4205:
URL: https://github.com/apache/iggy/pull/4205#issuecomment-5711053968

   Storage direction is right, and the doc is unusually well grounded. I checked the Iggy-side claims against the tree and they hold, including the load-bearing one: a named consumer hashes to a `u32` and can collide, a named consumer group resolves through metadata to a monotonic id.
   
   Two substantive things.
   
   ## Idempotence: point it at our dedup instead of allocating ids
   
   We don't do Kafka-style idempotence and won't. What we do have, landed and on by default, is partition-plane dedup keyed on `(client_id, user_id, request)`, where `client_id` is a `u128` the client generates. The watermark is per consensus group, so per partition, with a 128-deep committed window below it. Sized by `[partition] dedup_clients_max`, 4096 per group, ceiling 65536. It covers retried produces explicitly.
   
   That is close to Kafka's key shape. Producer id plus a per-partition sequence maps onto session id plus request id, per partition on both sides, and our window is wider than the 5 batches Kafka's producer keeps.
   
   The catch is which hop it protects. Our dedup covers gateway to Iggy. Kafka idempotence covers producer to gateway. A producer retry arrives as a fresh Produce request, the gateway makes a fresh Iggy send with a fresh request id, and nothing absorbs it. To make this count, the gateway has to derive both halves of the key from the Kafka request: session id from the producer id, request id from the base sequence.
   
   Two SDK gaps sit in the way. `ConsensusSession::with_client_id` exists and is `pub`, but `TcpClient` hardcodes `ConsensusSession::new()` (`tcp_client.rs:378`, `:583`), so nothing plumbs a chosen id through the builder. And `next_request_id` is an internal monotonic counter with no caller-supplied form. Both live in the same area as the open session-resume work.
   
   What the mapping does and does not buy, so the doc can be honest about it:
   
   - Duplicate suppression on retry: yes, and that is what `enable.idempotence=true` buys most users.
   - The original offset back on an absorbed duplicate: no. A dedup hit answers the operation's empty success with no base offset, so the retry surfaces an unknown offset.
   - Gap detection: no. The watermark accepts anything above it without noticing a hole, so never sending 45 or 46 stays correct.
   - Fencing: no. Partition slices carry no epoch, so there is no producer-fenced equivalent.
   - It degrades quietly. At `dedup_clients_max` the oldest client entry is evicted and its next replay re-executes, so the guarantee weakens as producer count per partition grows.
   
   Your producer id layout gets more useful under this, not less. The producer id is what a session id would be derived from, and cross-instance uniqueness is what stops two gateways sharing a dedup key. Please also say whether that counter survives a gateway restart, since a counter that resets reissues ids and breaks the same layer the layout exists to protect.
   
   Transactions stay out, permanently. The unsupported-version answer for a transactional id and the reasoning about the Java client's fatal set are both right. Keep them.
   
   ## Four things in the mapping doc
   
   1. An empty record key has no path. Kafka separates a null key from a zero-length one, the key is stored as a header value, and an empty header value is rejected at `user_headers.rs:631`, the same line cited for the 255-byte cap. The fallback list covers a key that is too long but not an empty one, and the null-and-empty section covers values only. Such a record either fails to store or comes back with a null key.
   
   2. The decompression bound is per batch where it has to be per request. One frame can carry many batches, bounded only by the 4096-element budget in `bounds_guard.rs`, so the real ceiling is that times `max_frame_size` rather than `max_frame_size`. This is the same product-across-nested-arrays shape `MAX_REQUEST_ELEMENTS` was added for, and that module's doc has the history.
   
   3. Header order is not preserved and the doc does not say so. User headers live in a `BTreeMap` ordered by kind then bytes, so Fetch emits them sorted by name rather than in producer order. Duplicates are handled by the envelope, order is not mentioned anywhere.
   
   4. OffsetFetch with a null topic list cannot reverse the topic mapping. `TopicMapping::resolve` is one way and an override can point at a different stream, so enumerating one stream both misses topics and hands back Iggy-side names where Kafka names are required.
   
   ## Process
   
   #3533 is closed, so the mapping doc has no open issue to land under, and #3540 asks for sign-off on options A, B or C while this proposes a fourth. Worth reopening something or filing a docs issue so the epic checklist tracks these three files. I would drop the 22 September default-if-no-answer clause, since #3540's own acceptance criteria call for maintainer sign-off.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031323959


##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |
+| record offset | partition offset, assigned by Iggy |
+| partition index | partition index, both 0-based |
+| topic | stream and topic per `TopicMapping` |
+
+Fetch reverses it. A message with no `kafka.*` headers is a message an Iggy client wrote, and
+encodes as a Kafka record with a null key, its Iggy user headers as Kafka headers, and
+`origin_timestamp` as the record timestamp (falling back to the server-assigned `timestamp`
+when the origin timestamp is zero). Iggy header kinds other than `Raw` and `String` are emitted
+as their raw value bytes.
+
+## Records Iggy cannot hold natively
+
+Iggy rejects an empty payload (`core/common/src/types/message/iggy_message.rs:169`), caps a
+user header value at 255 bytes (`core/common/src/types/message/user_headers.rs:631`), keys
+headers in a `BTreeMap` so a name cannot repeat, and caps all user headers of a message at
+100 KB (`MAX_USER_HEADERS_SIZE`). Kafka allows all of the shapes those rules exclude, so two
+mechanisms cover them.
+
+### Null and empty values
+
+A record with a null value (a tombstone) or a zero-length value is stored with a single `0x00`
+byte payload and a `kafka.value` header holding `null` or `empty`. Fetch reads that header and
+restores the original, discarding the placeholder byte.
+
+This keeps tombstones on the fast path rather than pushing them into the fallback, because they
+are ordinary traffic on compacted Kafka topics. Iggy has no compaction, so a tombstone is stored
+and served like any other record and nothing acts on it.
+
+### Everything else: the envelope fallback
+
+A record takes the fallback when any of these hold:
+
+- the key is longer than 255 bytes
+- a header name, prefixed with `kafka.h.`, is longer than 255 bytes
+- a header value is null, empty, or longer than 255 bytes
+- two headers share a name
+- the headers together would exceed the 100 KB user-header budget
+
+Such a record is stored with a `kafka.envelope` header carrying the format version, and the
+Kafka record body (key, value, headers) verbatim in the payload. Fetch checks for that header
+first and takes the plain path only when it is absent.
+
+The cost is that these messages are opaque to Iggy consumers and connectors. That is the point
+of confining the fallback to record shapes that are rare in practice, rather than making it the
+default storage form.
+
+## Batch-level fields
+
+Per-record storage drops what the Kafka record batch header carries: producer id, producer
+epoch, base sequence, the transactional flag, compression and the batch CRC. Fetch synthesizes
+a batch with producer id `-1`, epoch `-1`, base sequence `-1`, no compression, `CreateTime`
+timestamps, and a recomputed CRC32C.
+
+Two consequences worth stating before they surprise someone:
+
+- Idempotent-producer deduplication cannot be reconstructed from stored data later. If
+  [#3545](https://github.com/apache/iggy/issues/3545) ever grows past a stub, producer id,
+  epoch and sequence need their own tracking.
+- The bytes a consumer receives are not the bytes the producer sent, so anything comparing
+  batches byte for byte across the gateway will differ.
+
+Whether producer id `-1` is what Fetch actually sends depends on the InitProducerId decision in
+[`IDEMPOTENCE.md`](IDEMPOTENCE.md). Allocating producer ids does not change what is stored, only
+what Produce accepts, so this section holds under either answer.
+
+Produce decompresses gzip, snappy, lz4 and zstd batches, which means turning those features back

Review Comment:
   How to handle decompressed message exceeds IGGY_KAFKA_MAX_FRAME_SIZE ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031372725


##########
gateways/kafka/docs/IDEMPOTENCE.md:
##########
@@ -0,0 +1,92 @@
+# InitProducerId and idempotent producers
+
+Status: proposed. Answers the open half of
+[#3545](https://github.com/apache/iggy/issues/3545) and gates the Phase 1 end-to-end test
+([#3539](https://github.com/apache/iggy/issues/3539)), which drives
+`kafka-console-producer.sh`.
+
+## The problem
+
+A stock Java producer sets `enable.idempotence=true` without being asked. That default arrived
+in Kafka 3.0 and took effect from 3.0.1, 3.1.1 and 3.2.0, where a bug that suppressed it was
+fixed. `kafka-console-producer.sh` leaves it on.
+
+An idempotent producer sends InitProducerId (key 22) before its first record. The gateway does
+not list key 22, so ApiVersions does not advertise it, and the producer raises
+`UnsupportedVersionException`. That exception is fatal.
+`TransactionManager.maybeTransitionToErrorState` tests it above the `isTransactional()` branch.
+The producer therefore enters a fatal error state instead of dropping back to weaker semantics.
+It fails at startup, before it sends a record.
+
+The gateway's stated purpose is that a Kafka user swaps the broker and changes no application
+code. A broker that the default producer cannot start against does not meet it.
+
+## Options
+
+| Option | Cost | What a stock producer does |
+| -------- | ------ | ---------------------------- |
+| Stub with `UNSUPPORTED_VERSION` | none | fails at startup unless the user sets `enable.idempotence=false` |
+| Allocate only | about a day | works untouched, at-least-once delivery |
+| Real deduplication | large | works untouched, exactly once per partition, single gateway instance only |
+
+Real deduplication means tracking a sequence number per producer and per partition, and
+rejecting a duplicate or a gap. It is correct only while one gateway instance sees every write
+from a producer, so it cannot be decided before the multi-instance question is.
+
+## Decision
+
+Allocate only.
+
+Rejecting the stock producer to avoid implementing deduplication trades the one requirement the
+maintainers named against a guarantee Iggy does not offer today anyway. Allocating costs about
+a day and keeps delivery exactly where it already is.
+
+## Behavior
+
+Add key 22 to `SUPPORTED_RANGES` in `src/protocol/api.rs` and advertise it through ApiVersions.
+Without both, the producer never sends the request. `kafka-protocol` 0.18 carries the schemas,
+request v0 to v5 and response v0 to v6, flexible from v2.
+
+InitProducerId with no `transactional_id`:
+
+- allocate the next producer id, return it with epoch 0 and error code 0
+- draw ids from a counter seeded per gateway instance, so two instances never hand out the same
+  id. Nothing reads the id today. Seeding it now is what stops a later deduplication layer from
+  being born broken
+
+InitProducerId with a `transactional_id`:
+
+- answer `UNSUPPORTED_VERSION` (35), unchanged. Transactions stay out of scope, and so do

Review Comment:
   Should it be 35 or Use a feature error (INVALID_REQUEST / transactions-not-supported)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031403663


##########
gateways/kafka/docs/OFFSET_STORAGE.md:
##########
@@ -0,0 +1,132 @@
+# Consumer offset storage
+
+Status: proposed. Answers [#3540](https://github.com/apache/iggy/issues/3540) and blocks
+[#3542](https://github.com/apache/iggy/issues/3542), OffsetCommit and OffsetFetch.
+
+## Decision
+
+Store Kafka group offsets as Iggy consumer offsets, one key per partition, under a consumer
+group whose name is derived from the Kafka group id.
+
+The issue lists three options. None of them is this one.
+
+| Option | Why not |
+| -------- | --------- |
+| A, an Iggy-backed `__consumer_offsets` topic | Rebuilds what Iggy already has. A compacted offset topic needs compaction, which Iggy does not have, so the gateway replays the whole topic at every startup |
+| B, a SQLite file on the gateway host | A second durability story, a second backup story, and offsets that do not survive moving the gateway |
+| C, in memory only | Fails the acceptance criterion in #3542, which is that offsets survive a restart |
+
+Iggy already stores a durable offset per consumer and per partition, replicated with the
+partition itself. Using it costs one call per partition on commit and one on fetch.
+
+## The key
+
+One Iggy consumer offset per Kafka `(group, topic, partition)`.
+
+- consumer kind: `ConsumerKind::ConsumerGroup`
+- consumer id: `Identifier::named("kafka.cg.<group>")`
+- stream and topic: whatever `TopicMapping` resolves the Kafka topic to
+- partition: the Kafka partition index, unchanged, because both sides number from 0
+
+The gateway calls `create_consumer_group(stream, topic, "kafka.cg.<group>")` before the first
+commit for a group on a topic. If the group does not resolve in metadata, the server rejects the
+offset write. The group has to exist first. The gateway never joins the group. Offsets are
+readable by any client, member or not.
+
+### Why the group kind and not a named consumer
+
+`ConsumerKind::Consumer` with a name looks simpler, because it needs no registration call. It is
+not. The server hashes a named consumer id to a `u32` with `XxHash32`
+(`core/server/src/dispatch/partition.rs:916`), and that hash is the offset key. Two different
+group names can collide and silently share one offset.
+
+A consumer group name resolves through metadata to a monotonic id instead. No hash, no
+collision, and `get_consumer_groups(stream, topic)` lists what exists.
+
+### Why the prefix
+
+`kafka.cg.` keeps a Kafka group called `orders` off the key that a native Iggy consumer group
+called `orders` uses. Without it the two share an offset and each one moves the other.
+
+The prefix does not make the offsets safe to poll with. That is the next section.
+
+## What is stored
+
+The Kafka committed offset, verbatim, with no conversion.
+
+The two systems mean different things by the number. Kafka commits the next offset to read.
+Iggy stores the last offset processed, and `PollingKind::Next` resumes at the stored value plus
+one (`core/partitions/src/iggy_partition.rs:3835`). A Kafka offset stored in an Iggy key is
+therefore one greater than Iggy's own convention for that key.
+
+This is inert because the gateway never polls that way. Fetch always polls with an explicit
+offset, `PollingKind::Offset`, taken from the Kafka request. Nothing in the gateway reads the
+stored value to decide where to resume. It is returned to the client on OffsetFetch and
+otherwise untouched.
+
+The rule this creates: no code path polls a `kafka.cg.*` key with `PollingKind::Next`. Doing so
+skips one record per partition. The prefix is what keeps a native Iggy consumer from doing it by
+accident.
+
+Converting on write instead, and storing the Kafka offset minus one, breaks at offset 0. It also
+makes an empty commit look the same as a commit of the first record. Storing verbatim is the
+smaller problem.
+
+## OffsetFetch with no topics named
+
+OffsetFetch v2 and later let a client pass a null topic list, which asks for every offset the
+group holds. `kafka-consumer-groups.sh --describe` does this.
+
+Iggy has no lookup by consumer. Offsets are read one partition at a time
+(`core/common/src/traits/consumer_offset_client.rs:41`). The gateway answers by enumerating the
+topics in the mapped stream and querying each partition of each one.
+
+That is one round trip per partition on an admin call. The cost is bounded by the topic and
+partition count of one stream. This is an admin path and not a data path, so the cost is
+acceptable. It is written here so nobody discovers it in a test.
+
+## What is dropped
+
+Kafka lets a client attach a metadata string to a commit. Iggy stores a number and nothing else.
+The string is dropped on commit, and OffsetFetch returns an empty string.
+
+`committed_leader_epoch` is dropped the same way. The gateway reports `-1`.
+
+## Limits
+
+A partition admits a bounded number of distinct offset keys per consumer kind. The default is

Review Comment:
   4096 offset keys/partition/kind → Kafka -1 UNKNOWN_SERVER_ERROR. Multi-tenant group count will hit this with no useful client retry. Call the operator knob (partition.consumer_offsets_max) in README



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] docs(gateways): settle the Kafka record mapping, producer ids, offsets [iggy]

Posted by "ryerraguntla (via GitHub)" <gi...@apache.org>.
ryerraguntla commented on code in PR #4205:
URL: https://github.com/apache/iggy/pull/4205#discussion_r4031248903


##########
gateways/kafka/docs/BRIDGE_MAPPING.md:
##########
@@ -0,0 +1,204 @@
+# Kafka to Iggy record mapping
+
+Status: proposed. Direction agreed with @spetz and @hubcio on 2026-09-16 ("messages should be
+stored in iggy format"); the escape hatches below still need sign-off. Closes the last open
+scope item of [#3533](https://github.com/apache/iggy/issues/3533) and blocks
+[#3535](https://github.com/apache/iggy/issues/3535) (Produce) and
+[#3536](https://github.com/apache/iggy/issues/3536) (Fetch).
+
+## Decision
+
+One Kafka record becomes one Iggy message, in Iggy's own format: the record value is the
+message payload, the key and the Kafka headers become Iggy user headers. The gateway rebuilds
+a Kafka record batch on Fetch.
+
+Two properties drive this.
+
+A Kafka consumer must be able to read a topic an Iggy producer wrote. This is the staged
+migration the maintainers described: rewrite producers to the Iggy SDK first, leave consumers
+on the gateway until later. The gateway can only encode an arbitrary Iggy message as a Kafka
+record if the stored form has no Kafka framing in it.
+
+Kafka offsets must line up with Iggy offsets. A Kafka record batch carries N records under one
+base offset, while an Iggy message consumes exactly one offset. Storing a batch whole makes
+every offset the gateway reports wrong by the batch size, and fixing that inside Iggy means
+teaching the server to count records inside an opaque payload.
+
+Storing the Kafka payload and headers as a dump inside the Iggy payload was the alternative
+raised in the same thread. It does not satisfy the first property on its own: the gateway would
+still need a native path for Iggy-written messages, so it would carry two storage formats
+instead of one. Native storage with a narrow fallback (see below) keeps that to one.
+
+## Field mapping
+
+Produce, per record:
+
+| Kafka | Iggy |
+| ------- | ------ |
+| record value | `payload` |
+| record key | `kafka.key` user header, `Raw` |
+| record header `name` | `kafka.h.<name>` user header, `Raw` |
+| record timestamp (CreateTime) | `origin_timestamp` |

Review Comment:
   While converting, make sure of the resolution, milli seconds in Kafka to microSeconds in Iggy



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@iggy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org