KAFKA-17019: Producer TimeoutException should include root cause #20159
+55
−10
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.
Changes
PotentialCauseException
.org.apache.kafka.common.errors.TimeoutException
inKafkaProducer
hasPotentialCauseException
as root cause if itcannot catch any exception.
Describe
TimeoutException
can be thrown for various reasons.However, it is often difficult to identify the root cause,
Because there are so many potential factors that can lead to a
TimeoutException
.For example:
ProducerClient
might be busy, so it may not be able to send therequest in time. As a result, some batches may expire, leading to a
TimeoutException
.broker
might be unavailable due to network issues or internalfailures.
handles and responds to it, the response might arrive slightly late.
As shown above, there are many possible causes. In some cases, no
exception
is caught in thecatch
block, and aTimeoutException
isthrown simply by comparing the
elapsed time
. However, the developerusing
TimeoutException
inKafkaProducer
likely already knows whichspecific reasons could cause it in that context. Therefore, I think it
would be helpful to include a
PotentialCauseException
that reflectsthe likely reason, based on the developer’s knowledge.