Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metadata order in response when producing records #945

Merged
merged 3 commits into from
Nov 25, 2024

Conversation

robobario
Copy link
Contributor

fix: preserve record send order in response metadata

This uses the send CompletionStages to keep the original ordering of records.

kafka-clients KafkaProducer#send only guarantees that callbacks are executed in order per partition, the ordering across partitions is not guaranteed.

Callbacks for records being sent to the same partition are guaranteed to execute in order. That is, in the following example callback1 is guaranteed to execute before callback2:

producer.send(new ProducerRecord<byte[],byte[]>(topic, partition, key1, value1), callback1);
producer. send(new ProducerRecord<byte[],byte[]>(topic, partition, key2, value2), callback2);

Closes #944

This uses the send CompletionStages to keep the original ordering of
records.

kafka-clients Producer#send only guarantees that callbacks are executed
in order per partition, the ordering of partitions is not guaranteed.

Signed-off-by: Robert Young <[email protected]>
@robobario
Copy link
Contributor Author

the ppc64le build failed with:

SeekIT.seekToOffsetMultipleTopicsWithNotSuscribedTopic(VertxTestContext) java.lang.AssertionError: 
Expected: is "No current assignment for partition seekToOffsetNotSubscribedTopic-0"
     but: was "No current assignment for partition seekToOffseSubscribedTopic-0"

doesn't sound related to produce changes

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

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

LGTM! Good catch @robobario! Thanks!

@ppatierno ppatierno requested a review from scholzj November 25, 2024 10:22
Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

LGTM if it works.

@ppatierno ppatierno added this to the 0.31.0 milestone Nov 25, 2024
@ppatierno ppatierno merged commit 565d89d into strimzi:main Nov 25, 2024
13 checks passed
@ppatierno
Copy link
Member

I am going to cherry-pick this one for the release-0.31.x branch for having it in the 0.31.0 release.

ppatierno added a commit to ppatierno/strimzi-kafka-bridge that referenced this pull request Nov 25, 2024
* Add integration test checking result ordering

Signed-off-by: Robert Young <[email protected]>

* fix: preserve record send order in response metadata

This uses the send CompletionStages to keep the original ordering of
records.

kafka-clients Producer#send only guarantees that callbacks are executed
in order per partition, the ordering of partitions is not guaranteed.

Signed-off-by: Robert Young <[email protected]>

* Updated CHANGELOG with metadata fix description

Signed-off-by: Paolo Patierno <[email protected]>

---------

Signed-off-by: Robert Young <[email protected]>
Signed-off-by: Paolo Patierno <[email protected]>
Co-authored-by: Paolo Patierno <[email protected]>
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.

Produced Records result offset order not deterministic
3 participants