Skip to content

🐛 fix(sink/kafka): require all acks to prevent silent message loss (REL-07) - #166

Merged
konih merged 1 commit into
mainfrom
fix/rel-07-kafka-acks
Aug 2, 2026
Merged

konih merged 1 commit into
mainfrom
fix/rel-07-kafka-acks

Conversation

@konih

@konih konih commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

REL-07 (P2) — Kafka sink was fire-and-forget (silent data loss)

Surfaced by the 2026-08-02 /project-audit (reliability lens). The Kafka writer was built as a struct literal &kafka.Writer{...} with RequiredAcks unset — which bypasses kafka-go's NewWriter 0→RequireAll coercion, leaving the effective value at RequireNone. WriteMessages could return nil before the broker persisted → events silently lost on post-accept broker/leader failure, no error surfaced.

Fix

Set RequiredAcks: kafka.RequireAll explicitly on the writer. Async/Completion are unset so WriteMessages is synchronous and returns the ISR-ack error, which the caller (pipeline/wire.go:174) already treats as a failure.

Review

Independent reviewer: APPROVE, no findings — verified the fix is on the real writer, the caller treats ack errors as failures (not fire-and-forget), and the test is a genuine regression guard needing no broker. Gates green.

Copilot AI review requested due to automatic review settings August 2, 2026 10:57
@konih
konih merged commit c78ab77 into main Aug 2, 2026
22 checks passed
@konih
konih deleted the fix/rel-07-kafka-acks branch August 2, 2026 10:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the Kafka sink’s delivery guarantees by explicitly requiring ISR acknowledgements, eliminating a “fire-and-forget” default that could silently drop events after broker/leader failure.

Changes:

  • Set RequiredAcks: kafka.RequireAll on the struct-literal kafka.Writer to avoid the NewWriter default-coercion bypass.
  • Add a regression unit test ensuring NewBackend constructs a writer with RequireAll acks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/sink/kafka/backend.go Explicitly configures the Kafka writer to require all in-sync replica acknowledgements.
internal/sink/kafka/backend_test.go Adds a regression test asserting RequiredAcks is set to kafka.RequireAll.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

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.

2 participants