Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public class ProducerConfig extends AbstractConfig {
+ "Enabling idempotence requires this config value to be greater than 0."
+ " If conflicting configurations are set and idempotence is not explicitly enabled, idempotence is disabled."
+ "<p>"
+ "Allowing retries while setting <code>enable.idempotence</code> to <code>false</code> and <code>" + MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION + "</code> to 1 will potentially change the"
+ "Allowing retries while setting <code>enable.idempotence</code> to <code>false</code> and <code>" + MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION + "</code> to greater than 1 will potentially change the"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The comment with your correction is correct -- retries can reorder records when idempotency is not enabled and in flight requests > 1.

However, there are also some edge cases where even one inflight request could see duplicates or re-ordering when multiple connections are involved (this is due to tcp level interactions). I'm not sure if that was ever the intention of this document but it was something that came up recently and is problem not well known.

Moral of the story is that only idempotency promises no duplicates or reordering :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good to know, thanks for the info, could you provide more info on when a re-ordering (not so interested on duplicates for my use case) can happen, if there is a really unlikely edge case we may live with it.
On the other hand, do you have an idea of how slow is using using idempotency vs in flight requests =1?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the case where a connection is closed on the client side, it can still arrive later on the server. Even though the client disconnects and resumes with a new connection, a message from the old connection can come in out of order. This can happen when there is a temporary network issue.

I don't have metrics on latency comparisons with idempotency vs infligh requests = 1, but I wouldnt suspect it should be too much. Idempotency involves a sequence check broker side which shouldn't take too much time per produce request. It would be an interesting test to do.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cool, thanks for info!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure if we wanted to include a note about this or not. Just something like noting that inflight requests = 1 does not guarantee idempotency due to how TCP connections work with Kafka.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I guess that if that is the case the whole comment is a little outdated, since no matter inflight requests value but just idempotency to guarantee partition ordering, not for me to decide about this, but I think that this point should be clear as ordering is an important feature of kafka partitions.

Copy link
Copy Markdown
Author

@federico-weisse-sportsbet federico-weisse-sportsbet Feb 23, 2024

Choose a reason for hiding this comment

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

In any case reconsidering the case of the connection closed on client side, if inflight = 1, it should send one batch at a time, so, I wonder if that case is no more about duplicated messages than re-ordering.
I guess the only way to have an un-orderer is if the broker gets first new connection batches, like
new_conn_batch1, new_conn_batch2, old_conn_batch1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah something along the lines of that

+ " ordering of records because if two batches are sent to a single partition, and the first fails and is retried but the second"
+ " succeeds, then the records in the second batch may appear first.";

Expand Down