Skip to content

[kafka] Implement Metadata API over Fluss table metadata - #4261

Draft
gyang94 wants to merge 5 commits into
apache:mainfrom
gyang94:codex/kafka-metadata-api
Draft

[kafka] Implement Metadata API over Fluss table metadata#4261
gyang94 wants to merge 5 commits into
apache:mainfrom
gyang94:codex/kafka-metadata-api

Conversation

@gyang94

@gyang94 gyang94 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Purpose

Closes #4266. Part of #4185.

Expose pre-created Fluss tables through Kafka Metadata using the shared DDL mapping contract. Compatible tables return routing metadata; incompatible mappings are omitted from all-topic discovery and produce a per-topic error in named queries, while other valid topics remain discoverable.

This is PR04 of the foundation sequence, depending on PR03 DDL table mapping (#4277 / #4275), which builds on PR02 ApiVersions (#4260 / #4265) and PR01 (#4259 / #4264).

Brief change log

  • Implement Metadata v0-v11 with a narrow backend contract and a TabletServer gateway adapter, and register it in ApiVersions.
  • Reuse the DDL prerequisite's topic identity mapper and schema resolver. Read the descriptor from the existing table_json metadata field.
  • Return only compatible tables in all-topic queries. Named queries return INVALID_TOPIC_EXCEPTION for incompatible mappings and UNKNOWN_TOPIC_OR_PARTITION for missing tables, without suppressing valid topics in the same request.
  • Map brokers, partitions, leaders, replica assignments, authoritative ISR, and offline replicas while preserving the Kafka listener context.
  • Handle invalid/missing names, table-deletion races, unavailable leaders, and gateway failures. Reject ID-only lookup in v10/v11.
  • Preserve the conservative available-leader ISR fallback for legacy metadata; when a bucket epoch is present, honor authoritative ISR even when empty or when the epoch is -1.

Relative to the DDL prerequisite: 9 files, +1477 / -4 lines (1481 changed lines including tests). Shared DDL mapping implementation and tests belong to #4277 and are excluded from this incremental scope. The Metadata protocol, gateway adaptation and version/error regression coverage are kept together as one review unit.

Tests

Validated on Java 11 at commit 050b26088ba0e9fbd7b5db7851da1688d6715b73:

  • mvn -o -pl fluss-kafka clean verify: 62 unit tests and 2 integration tests passed.
  • Coverage includes v0-v11 discovery with compatible/incompatible/missing tables, mapping changes with stable topic identity, gateway failures, listener propagation, buffer ownership, and legacy/authoritative ISR behavior.
  • Integration tests cover Kafka request transport and the native Fluss DDL mapping round trip.
  • Checkstyle, Spotless, RAT and git diff --check passed. Matching dependencies were built/installed with mvn -o -pl fluss-kafka -am install -DskipTests.

The full repository test suite and a Flink SQL runtime were not run.

API and Format

Adds Kafka Metadata v0-v11 for tables that satisfy the current DDL mapping contract. Existing Fluss RPC and storage formats are reused. Kafka CreateTopics/DeleteTopics, automatic table creation, Metadata v12+, Produce, and JSON record conversion remain outside this PR.

Documentation

The supported versions, DDL admission rules and per-topic errors are described in this PR, source Javadoc and regression tests. Produce delivery documentation follows with later capability work.

Stack and review

  1. [kafka] Add request dispatch and transport framework #4259 — PR01: request and transport framework.
  2. [kafka] Serve ApiVersions from registered capabilities #4260 — PR02: ApiVersions.
  3. [kafka] Define DDL table mapping for Kafka compatibility #4277 — PR03: DDL table mapping contract.
  4. This PR — PR04: Metadata.

This PR remains a draft until its prerequisites land. It targets Apache main, so GitHub's Files changed view includes the foundation prerequisites. Review Metadata alone using the incremental comparison against DDL mapping. The DDL prerequisite is integrated without rewriting the previously published Metadata history. Update the baseline after prerequisites merge and validate again before marking ready.

Generative AI disclosure: Codex assisted with implementation, testing, and commit organization. Human review is required before merge.

gyang94 and others added 3 commits September 9, 2026 14:04
Introduce API registration, request context, version validation, and
asynchronous error mapping. Fix request buffer ownership and response
serialization cleanup while preserving the existing ApiVersions entry point.

Validated with mvn -o -pl fluss-rpc,fluss-kafka verify.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 555/555
AI-Contributed/UT: 525/525
Route requests through the dispatcher and advertise only implemented APIs.
Return version-aware errors for unsupported APIs and invalid requests.

Validated with mvn -o -pl fluss-kafka verify (23 unit tests and 1 IT).

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 313/313
AI-Contributed/UT: 137/137
Add Metadata v0-v11 handling over pre-created Fluss tables, with listener-aware
gateway access, table/topic mapping, partition metadata, and error handling.
Do not implement CreateTopics, DeleteTopics, or automatic table creation.

Honor authoritative ISR values when bucket epochs are present. For legacy
metadata without an epoch, conservatively report only an available leader.

Verified fluss-kafka: 37 unit tests and 1 integration test, with Spotless and
Checkstyle passing. Rebuilt the matching RPC dependency from the same base.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 909/909
AI-Contributed/UT: 540/540
gyang94 and others added 2 commits September 10, 2026 15:28
Extract topic identity and the raw/string table mapping contract before Metadata. Validate table kinds, field projections and metadata columns independently of request handling and record decoding.

Validation: Java 11, mvn -o -pl fluss-kafka clean verify (47 unit tests and 2 integration tests); Checkstyle, Spotless and RAT passed.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 769/769
AI-Contributed/UT: 480/480
Integrate the DDL mapping prerequisite and use its resolver for Metadata discovery. Omit unsupported tables from all-topic queries and return per-topic mapping errors for named queries. Preserve metadata for compatible tables in mixed requests.

Validation: Java 11, mvn -o -pl fluss-kafka clean verify (62 unit tests and 2 integration tests); Checkstyle, Spotless and RAT passed.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 742/742
AI-Contributed/UT: 571/571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kafka] Implement Metadata API for pre-created Fluss tables

1 participant