Skip to content

MINOR: Improve docs for retries & cleanup #19595

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

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

lianetm
Copy link
Member

@lianetm lianetm commented Apr 29, 2025

Improve docs for retries config, mainly to clarify the expected
behaviour on retries=0 Also remove unused funcs and fix typo.

private static final String RETRIES_DOC = "Number of times to retry a request that fails with a transient error."
+ " Setting a value greater than zero will cause the client to resend any record whose send fails with a potentially transient error. "
+ " Requests will be retried this many times until they succeed, fail with a non-transient error, or the <code> DELIVERY_TIMEOUT_MS_CONFIG </code> expires."
+ " Note that this automatic retry is no different than if the client resent the record upon receiving the error."
Copy link
Member

Choose a reason for hiding this comment

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

Is this actually correct? I mean, internal retires are idempotent (at least by default, as long as idempotency is not disabled), while application retires are not idempotent.

Copy link
Member Author

Choose a reason for hiding this comment

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

well I would say it's correct saying that automatic retries won't mess around/change the request (and that would be exactly the same as if the client resent the request, without messing around with it). Assuming no one changes the request (us internally, or the client app), both retries on retriables would behave the same right? Makes sense?

Copy link
Member

Choose a reason for hiding this comment

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

that automatic retries won't mess around/change the request (and that would be exactly the same as if the client resent the request, without messing around with it

I am confused. I read "the client resent the request" as the application code calls send(...) again? Do I miss understand? If "the client resent the request" is not meaning app calls send(...) again, that what does it mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same page on the meaning (I also take it as "the client resent the request" == "application code calls send(...)").

And totally agree with you that this is wrong from the idempotence point of view, my point was only that I read it as making a valid point about the automatic retries not doing any magic, just resend. I changed the sentence, let me know

+ " Requests will be retried this many times until they succeed, fail with a non-transient error, or the <code> DELIVERY_TIMEOUT_MS_CONFIG </code> expires."
+ " Note that this automatic retry is no different than if the client resent the record upon receiving the error."
+ " Setting a value of zero will disable this automatic retry behaviour, so that the transient errors will be propagated to the application to be handled."
+ " Users should generally prefer to leave this config unset and instead use <code>" + DELIVERY_TIMEOUT_MS_CONFIG + "</code> to control"
+ " retry behavior."
+ "<p>"
+ "Enabling idempotence requires this config value to be greater than 0."
Copy link
Member

Choose a reason for hiding this comment

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

Given that idempotent producer is enabled by default, might be worth to rephrase this, too?

Copy link
Member Author

@lianetm lianetm Apr 30, 2025

Choose a reason for hiding this comment

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

well the trick is that there is a diff between user enabling idemp explicitly (then it does "require this config value to be greater than 0.", will throw otherwise), vs. user not setting the prop, in which case idemp is enabled by default as you said, but it does not required the retries >0 (If retries=zero it won't fail, it simply disables idempotence automatically and the retries=0 is respected). Makes sense?

Copy link
Member

Choose a reason for hiding this comment

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

If retries=zero it won't fail, it simply disables idempotence automatically and the retries=0 is respected.

That is very unexpected to me -- I would expect a config error. What is the reason for this? Sound like a footgun to me, if changing retries has this side effect. (Side effect are IMHO in general most likely a bad thing.)

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I agree with the feeling, but as it's often the case, it was a matter of a trade off, the reason explained here https://issues.apache.org/jira/browse/KAFKA-13673.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. Interesting.

@Yunyung
Copy link
Collaborator

Yunyung commented Apr 30, 2025

Thanks for the PR. I left just one minor.

@@ -100,7 +100,7 @@ public class ProducerConfig extends AbstractConfig {
+ "similar or lower producer latency despite the increased linger.";

/** <code>partitioner.adaptive.partitioning.enable</code> */
public static final String PARTITIONER_ADPATIVE_PARTITIONING_ENABLE_CONFIG = "partitioner.adaptive.partitioning.enable";
public static final String PARTITIONER_ADAPTIVE_PARTITIONING_ENABLE_CONFIG = "partitioner.adaptive.partitioning.enable";
private static final String PARTITIONER_ADPATIVE_PARTITIONING_ENABLE_DOC =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also typo.

Suggested change
private static final String PARTITIONER_ADPATIVE_PARTITIONING_ENABLE_DOC =
private static final String PARTITIONER_ADAPTIVE_PARTITIONING_ENABLE_DOC =

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll leave of the adaptive typo changes out, it probably makes sense to address them together when the public config can be fixed.

@@ -415,7 +415,7 @@ public KafkaProducer(Properties properties, Serializer<K> keySerializer, Seriali
this.transactionManager = configureTransactionState(config, logContext);
// There is no need to do work required for adaptive partitioning, if we use a custom partitioner.
boolean enableAdaptivePartitioning = partitionerPlugin.get() == null &&
config.getBoolean(ProducerConfig.PARTITIONER_ADPATIVE_PARTITIONING_ENABLE_CONFIG);
Copy link
Collaborator

@mingyen066 mingyen066 Apr 30, 2025

Choose a reason for hiding this comment

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

@m1a2st found that this is public interface and I found someone has previously renamed this config. The earlier conclusion was that we should submit a trivial KIP to deprecate this config.
#17908

Copy link
Member Author

@lianetm lianetm Apr 30, 2025

Choose a reason for hiding this comment

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

uh totally, good catch. Removed all the changes on this

@@ -88,8 +88,9 @@ public class CommonClientConfigs {
"If provided, the backoff per host will increase exponentially for each consecutive connection failure, up to this maximum. After calculating the backoff increase, 20% random jitter is added to avoid connection storms.";

public static final String RETRIES_CONFIG = "retries";
public static final String RETRIES_DOC = "Setting a value greater than zero will cause the client to resend any request that fails with a potentially transient error." +
" It is recommended to set the value to either zero or `MAX_VALUE` and use corresponding timeout parameters to control how long a client should retry a request.";
public static final String RETRIES_DOC = "It is recommended to set the value to either `MAX_VALUE` or zero, and use corresponding timeout parameters to control how long a client should retry a request." +
Copy link
Member

Choose a reason for hiding this comment

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

nit: We can change '`' to <code>, so we can have syntax on document.

Suggested change
public static final String RETRIES_DOC = "It is recommended to set the value to either `MAX_VALUE` or zero, and use corresponding timeout parameters to control how long a client should retry a request." +
public static final String RETRIES_DOC = "It is recommended to set the value to either <code>MAX_VALUE</code> or zero, and use corresponding timeout parameters to control how long a client should retry a request." +

before:
Screenshot 2025-04-30 at 3 24 22 PM

after:
Screenshot 2025-04-30 at 3 22 56 PM

@lianetm
Copy link
Member Author

lianetm commented Apr 30, 2025

Thank you all for the feedback! Comments addressed and answers inline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants