Repository navigation
Replace unused failover with fanout for WAL/CDC writes - #344
Conversation
Previously, produce() used primary/backup failover semantics — only the primary was called on the happy path, and the backup was a fallback on error. Configuring multiple producers (e.g. two Kafka clusters for dual-publish) only sent actual mutations to the first producer that succeeded, making true dual-publish impossible. Rewrite produce() to fan out to all configured producers via Flux.fromIterable().flatMap(). Unlike produceHeartBeat(), per-producer errors are not swallowed — any failure propagates and fails the overall Mono<Void>. Remove assert(producers.size <= 2) and the now-unused primaryIdx, backUpIdx, producePrimaryOnly, and producePrimaryAndBackUp members. Update WalSpec and CdcSpec to reflect the new semantics: - "all producers succeed" → verifyComplete - "any producer fails" → verifyError Closes kakao#343 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
516d6ed to
57eae50
Compare
|
Update (resolved): Confirmed by @em3s in #343 (comment): all-or-nothing is the intended policy — all producers must succeed, errors must propagate (no |
- Verify all producers receive the message (fanout) - Verify any producer failure propagates as error (all-or-nothing) - Verify fanout works with N>2 producers Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
|
@em3s Ready for review. Added ProducerListSpec (N=2, N=3 fanout + verify assertions) and updated the PR description accordingly. |
|
@eazyhozy quick review:
|
Add require(producers.isNotEmpty()) to fail fast on construction rather than silently completing without publishing anywhere. Add corresponding test case in ProducerListSpec. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
|
Fixed: added For the short-circuit nice-to-have: skipping for now — |
Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
|
Nice work. On a partial failure we can't yet tell which cluster failed, but monitoring will surface that either way, so let's leave it for a follow-up improvement. |
(cherry picked from commit e0d5e73)
Summary
Unify(see Note below) Replace the (effectively unused) primary/backup failover inproduce()withproduceHeartBeat()by replacing the primary/backup failover logic with an N-fanout.produce()with an N-way fanout for WAL/CDC writes;produceHeartBeat()is unchanged (already a fanout, monitoring-only). All configured producers receive every message; any per-producer error propagates and fails the overallMono<Void>.Closes #343
Changes
produce()usingFlux.fromIterable(producers).flatMap { it.produce(message) }.then()assert(producers.size <= 2),primaryIdx,backUpIdx,producePrimaryOnly, andproducePrimaryAndBackUprequire(producers.isNotEmpty())ininitblock to fail fast on empty configurationWalSpecandCdcSpec: replace failover-based scenarios with "all succeed → complete" and "any fails → error" casesProducerListSpec: directly testProducerListfanout behavior with N=2 and N=3 producers, includingverifyassertions that all producers receive the messageTest cases (WalSpec / CdcSpec)
Test cases (ProducerListSpec — new)
produce()verified via mockkverifyverifyError()ProducerList(emptyList())→IllegalArgumentExceptionproduce()verifiedHow to Test
AI Assistance
Note by @em3s
Reframed the summary to match the issue (#343): this replaces the effectively-unused primary/backup failover with an N-way fanout for WAL/CDC writes, rather than "unifying
produce()withproduceHeartBeat()."produceHeartBeat()is out of scope — it already fans out and is monitoring-only. Chosen semantics: any per-producer error fails the overallMono<Void>(we want to know when a dual-write cluster drops writes). The code already matches; only the summary wording changed.