Skip to content

Consumer returns NULL key/value for legacy MessageSet format (message.format.version < 0.11) since v2.5.0 #5549

Description

@delthas

Description

When consuming from a cluster or topic that stores messages in the legacy MessageSet format (log.message.format.version < 0.11, MsgVersion v0..v1), every message is delivered to the application with NULL key and NULL value: fetches succeed and offsets advance, but all payloads are NULL. Offsets and timestamps are correct. The consumer also raises errors such as:

Unsupported Message(Set) MagicByte 97 at offset 1525458452426752

Bisected to 6867b9f ("Fetch RPC prework: upgrade to v15", #4584, v2.5.0): since Fetch v12+ the response buffer is parsed as a flexible version, and the legacy MessageSet reader reads Message Key/Value with rd_kafka_buf_read_kbytes(), which switches to compact (varint) length parsing for flexible-version buffers. Legacy MessageSets always use fixed-width int32 length prefixes, so the first 0x00 length byte parses as a compact NULL and the reader drifts into the message bytes (the MagicByte 97 above is a payload byte). On v2.5.x fetches fail/stall instead; from v2.6.0 onwards messages are delivered with NULL key/value as described. Still present on v2.15.0/master.

Found in production through node-rdkafka 3.6.1 (librdkafka 2.12.0), consuming from Apache Kafka 3.9.1 brokers that pin log.message.format.version=0.10.2.2 for rolling-upgrade compatibility.

How to reproduce

Run any broker with log.message.format.version=0.10.2.2 (e.g. Apache Kafka 3.9 in ZooKeeper mode with inter.broker.protocol.version=0.10.2.2), produce keyed messages, consume them: all messages arrive with NULL key/value. The fix PR adds a mock-broker regression test (0187) that reproduces this by capping the ProduceRequest version to <= v2 so the producer writes MsgVersion v1/v0 MessageSets.

Checklist

  • librdkafka version: v2.15.0 (also 2.6.0, 2.8.0, 2.11.1, 2.12.0, 2.14.2; regression since v2.5.0, bisected to 6867b9f)
  • Apache Kafka version: 3.9.1 with inter.broker.protocol.version=0.10.2.2, log.message.format.version=0.10.2.2
  • librdkafka client configuration: default, auto.offset.reset=earliest
  • Operating system: Linux (x64)
  • Provide logs: Unsupported Message(Set) MagicByte 97 at offset 1525458452426752 (_NOT_IMPLEMENTED) on every fetch
  • Provide broker log excerpts: no broker-side errors (messages stored intact, verified with DumpLogSegments)
  • Critical issue

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions