Repository navigation
kafka-out: the runtime writes a subject to a Kafka topic (ADR-0044 step 4) - #119
Merged
Merged
Conversation
…s delivery says Ctx::consume_batches gathers up to N messages (or a byte budget) from the durable pull consumer, hands them to the driver at once, and settles each as consume_carrying settles one: a hop, then an ack, a nak or a dead letter. While a batch is in hand a thread keeps its messages in progress every third of the ack wait. A message left when the unit stops or fails is given back at once, to come first. consume_with now shares its taking and settling with it. Puller::round_within asks the server to hold a round briefly, for the rounds that fill a batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT
…ep 4) The sink consumes its subject in batches through the shared durable consumer, produces with acks=all, one request at a time per partition, and acks each message once the broker answered for its record. A refusal that may clear holds the partition, tried again with a growing pause before any other message is taken. A record refused for good is a dead letter with the broker's reason; a request of several refused so is split until it stands alone. Keys go where the Java client's default partitioner puts them (murmur2, pinned with vectors the Java client computed); keyless messages take one partition per batch, in turn. Metrics, a probe that writes nothing, the topic in the topology. e2e/kafka.sh phase 10. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT
…t sent again The envelope joins a repeated header for a flow (ADR-0042). A sink that writes headers one by one reads them from Message::header_values, which gives each value apart, in the order it came; kafka-out writes them so, as ADR-0044 point 5 says. rskafka sent a produce again when its answer carried a throttle time. The broker throttles after the records are in the log, so each throttled answer wrote them once more: under a quota of 4 kB/s on Kafka 4.4.0, 200 messages became 636 records. The answer is read now, then the client waits out the throttle. e2e/kafka.sh checks a quota where it checked min.insync.replicas, which Kafka 4.4.0 does not enforce on a topic of one replica. The sdk's batch test runs in CI; the changelog and the book describe kafka-out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT
A mutant that sends a held request after the next one of its partition lived: the test held the last request. It holds the second of three now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT
…d when its topic is deleted Two checks in phase 10. Partitions added to the topic are written to once the unit reads the metadata again. A topic deleted under the sink is said, and the 50 messages it held are written once the topic is back: with the sdk acking a batch before its delivery, 40 of them were lost. The topic list is piped into matches, as the pipefail check asks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT
cpoder
marked this pull request as ready for review
December 5, 2026 10:03
…itions restart the unit H1. A pull round that failed once messages were in hand returned with them unsettled: no ack, no nak, and their +WPI stopped. The restarted unit wrote newer messages first, and these came back after their ack wait. The batch now ends there: what is in hand is delivered and settled, then the unit fails. sink::live checks it with a round that fails mid-batch. M2. A topic made again with fewer partitions kept the old count, and the batch held for good on a partition that no longer existed. A smaller count now fails the unit, which gives back what it holds and starts again on the new count; rskafka's missing-partition answer reads the metadata again. e2e/kafka.sh checks it. L1. A record with no time takes the time of each try, so a hold does not age it. L7. The partition count's messages name the driver that reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT
…4 Amendment C The module doc and the book say that each retry of a held request can write it again, with no fixed count, and that a try given up after 45 s can land after the next request; that a key keeps its order while the instance runs; that the sink opens one connection and one login per partition. Amendment C records the decisions of step 4 and the limits left as they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ADR-0044 step 4, PR 1 of 2: the
kafka-outdriver. PR 2, after this one, moves thekafka_sinkrecipe onto it.What it does
Ctx::consume_batches, a batch loop that keeps the hop, DLQ and ack rules ofconsume_within one place. kafka-out produces withacks=alland acks a message once the broker has answered for its record. A crash in between produces the record again when the bus delivers the message again.+WPI) for as long as they are held. A key's records keep their order within an instance. No idempotent producer.Message::header_valuesgives the values apart, where the envelope joins them for a flow.· no time: the time of the produce.Vejas-Emit-Idcomes from the emit id, andtraceparentandtracestatefrom the sink's span.TOPIC,SUBJECT(wildcards allowed),COMPRESSION(lz4 by default) andBATCH(500, at most 1000, the consumer'smax_ack_pending). Secrets are handled as in kafka-in.vejas_kafka_records_out_total,vejas_kafka_bytes_out_total,vejas_kafka_produce_errors_total, plusvejas_kafka_auth_errors_totalandvejas_kafka_records_refused_totalshared with kafka-in./topology.Found on the way: rskafka wrote a throttled produce again
PartitionClient::producetreated an answer that carries a throttle time like an error and sent the request again after the throttle. The broker throttles after the records are in the log, so each throttled answer wrote them once more, for as long as the broker throttled.The patch is in
third_party/rskafka/src/client/partition.rs, written down inPATCHES.md.Tests
kafka::out):sink::live, now a CI step inconnector-crate):ack_wait1 s is not delivered again;e2e/kafka.shphase 10 passes in CI on Apache Kafka 3.7.2 and 4.4.0 (run 47505358120, on 3ed6862), and locally on 4.4.0:Vejas-Emit-Id,traceparentcontinuing the trace,tracestate, the timestamp, and each key on its partition;MessageTooLarge, no payload is in the log, and the refused counter is 1;kill -9after about 4,000 of 20,000 messages: no gap, and copies only of what was in hand (0 to 52 locally; 166 on 3.7.2 and 6 on 4.4.0 in CI, with batches of 200), each with its message's id;Mutants
Each mutant was applied alone, run against the tests named, then undone.
unsigned_abs()in place of& 0x7fffffffin the partitioner0x9747b28din place of0x9747b28ca_refused_login_and_an_unknown_partition_are_told_apartsink::live, and by the deleted-topic check of phase 10: 10 of 50 records were written. Thekill -9check did not kill it in one run: the kill landed outside a produce+WPIwhile a batch is heldsink::liveAfter the review of 3ed6862 (9fd713f, 5ec01cf)
sink::live::a_round_that_fails_mid_batch_settles_what_is_in_handfails the second round of a 70-message backlog: the 64 in hand are delivered and acked, 6 stay pending, and the error comes back.Could not find metadata for partitionreads the metadata again. A unit test covers both, and a phase 10 check deletes a 3-partition topic and makes it again with 1: 30 messages, each once, each key in order.sink::live::a_round_that_fails_mid_batch_settles_what_is_in_handfewer_partitions_stop_the_unit_and_more_are_takenfewer_partitions_stop_the_unit_and_more_are_takena_record_with_no_time_takes_the_time_of_each_tryLeft out
record_errors). The patched client gives the error code, which the letter carries.acks=allwrites withmin.insync.replicas=2, so a one-broker cluster could not refuse that way. The hold is covered by the unit tests and the sdk's live test.🤖 Generated with Claude Code
https://claude.ai/code/session_018wXgxSSYsPm88PCqu98HPT