Skip to content

Support idempotent producers and committed reads - #432

Merged
PaxMachinaOne merged 3 commits into
KafScale:mainfrom
novatechflow:fix/28-java-producer-compatibility
Nov 25, 2026
Merged

PaxMachinaOne merged 3 commits into
KafScale:mainfrom
novatechflow:fix/28-java-producer-compatibility

Conversation

@novatechflow

@novatechflow novatechflow commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Default Java producers fail before their first message because KafScale does not advertise InitProducerId. Support nontransactional idempotence and committed reads in both brokers and the Kubernetes proxy, so default clients can produce without enable.idempotence=false.

  • Allocate fresh producer IDs through an etcd CAS counter, returning epoch 0. Preserve the existing metadata Store interface through an optional allocator interface.
  • Validate epochs and sequences under the partition append lock, retain the last five batch ranges, and acknowledge duplicates at their original offsets. Always flush new idempotent batches before success; rebuild state from validated S3 batches after restart or ownership handoff, including uncertain uploads and failed offset publication.
  • Advertise InitProducerId v0-v4 at both entry points. Support both Fetch/ListOffsets isolation levels for nontransactional records. Committed Fetch stops at the durable stable watermark and excludes volatile buffered data. Return schema-correct errors for unsupported transactional writes/control batches, including unavailable-backend responses at the proxy. Omit unsupported APIs from ApiVersions.
  • Count only newly appended messages in kafscale_produce_rps; deduplicated retries preserve offsets without inflating ingest throughput.
  • Update the support matrix, CLI/client examples, Java and Spring defaults, operations guidance, and unreleased notes. Transactions remain unsupported. Upgrade all brokers and proxies before enabling idempotence.

Testing

  • Kafka 3.9.1 Java default producer/consumer: 10 keyed records directly through the broker and 10 through the built proxy, using a local harness with embedded etcd and in-memory S3.
  • Kafka 3.9.1 Java response decoder accepted v8/v9 success and error responses; changing recordErrors to null reproduced the original rejection.
  • Default franz-go producer, concurrent etcd ID allocation, retry deduplication, epoch/sequence errors, uncertain-upload recovery, and etcd-backed A → B → restarted A ownership tests.
  • Proxy InitProducerId forwarding, unavailable backends, explicit transaction rejections, and preservation of idempotent batch identity during LFS rewriting.
  • Native kcat/librdkafka 2.16.0 end-to-end suite passed under -race through broker and proxy, including committed watermark queries and Fetch v4/v9/v13 in both isolation modes.
  • Committed reads hide buffered records until flush; stable-offset boundaries, legacy transactional-history rejection and duplicate ingest metrics have dedicated regressions.
  • go test -race ./pkg/storage ./pkg/metadata ./pkg/protocol ./pkg/broker ./cmd/broker ./cmd/proxy passed.
  • go test ./test/... passed, including chart and repository checks. go vet ./... and python3 hack/check_license_headers.py passed.
  • Kafka CLI e2e variants compile; Docker/MinIO round trips were not run locally because Docker is unavailable.

Limits: retry deduplication is scoped to the same producer session and recent batch window. Mixed duplicate/new multi-batch record sets are rejected before append. Transactional writes, coordinators, commit markers and cross-session exactly-once delivery remain unsupported. Restore refuses legacy transaction/control batches instead of exposing unverified transaction history.

Checklist

  • Added/updated unit tests for new logic
  • Added/updated e2e coverage for bug fixes
  • Added license headers to new files

Closes #28.

@PaxMachinaOne PaxMachinaOne left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two findings remain on this exact head:

  1. High — the transaction isolation gate breaks the existing librdkafka consume path on both broker and proxy. The hosted Go Integration Tests (kafka) check fails for the ordinary kcat -C ... -o beginning flow: its logical-END offset lookup receives Broker: API version not supported for both targets. The new pre-routing gate in pkg/protocol/unsupported_transactions.go:65-78 returns UNSUPPORTED_VERSION for any ListOffsets isolation value other than exactly zero; this now rejects the request emitted by the supported CI client before the existing ListOffsets handler runs. Restrict the rejection to an actual read_committed request (and handle versions without that field correctly), then add the exact librdkafka regression.

  2. Medium — deduplicated retries inflate kafscale_produce_rps. AppendIdempotentBatches returns the original offsets for a duplicate without appending, but cmd/broker/main.go:1309-1312 unconditionally adds every successful response batch to producedMessages. Retried idempotent batches therefore count as fresh ingest, making the documented broker ingest-throughput metric spike during retry incidents. Carry an appended-vs-duplicate result (or equivalent) and count only newly persisted messages; add a retry metric regression.

The focused idempotent producer, allocator, protocol, broker, proxy, and storage tests pass under -race. The broader local metadata race suite also hit the pre-existing timing-sensitive TestNonstopHeartbeatRaceEndsAtDeadline; the PR-specific tests passed. Hosted CodeQL and all other completed checks are green, but the Kafka integration check is red as described above.

@novatechflow novatechflow changed the title Support nontransactional idempotent producers Support idempotent producers and committed reads Nov 25, 2026

@PaxMachinaOne PaxMachinaOne left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the updated exact head. The prior blockers are fixed: ordinary librdkafka ListOffsets/FETCH paths now support both isolation modes for non-transactional records, while committed reads are fenced at the captured durable offset; deduplicated idempotent retries no longer increment produce-throughput metrics. The added restore rejection for transactional/control batches, volatile-tail handling, concurrent flush boundary, proxy parity, and recovery regressions are coherent. Focused and full storage/protocol/broker/proxy race suites pass, the hosted Kafka integration is green, and all completed hosted checks are green. No material findings.

@PaxMachinaOne
PaxMachinaOne merged commit 474d374 into KafScale:main Nov 25, 2026
25 checks passed
@novatechflow
novatechflow deleted the fix/28-java-producer-compatibility branch November 25, 2026 10:15
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.

JAVA_CLIENT Connection problem:

2 participants