-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
MINOR: Improve Producer error message for failed metadata update #18587
Open
mjsax
wants to merge
1
commit into
apache:trunk
Choose a base branch
from
mjsax:minor-producer-error-msg
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any value in including the
partition
value in the error message if it's non-null
?On line 1085 the method
waitOnMetadata()
exits whenpartitionsCount
is non-null
butpartition
isnull
. It seems like it's possible forpartitionsCount
to benull
butpartition
non-null
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are 3 cases too:
partitionsCount == null
meaning we don't know how many partitions there arepartitionsCount != null && partition == null
meaning we do know how many partitions there are but no partition was specifiedpartitionsCount != null && partition != null
meaning we do know how many partitions there are and a partition was specifiedSeems to me that 3 messages would be best so that we never get a "null" as an ugly insert. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
partition
is an input parameter to the method, and it's onlynull
if the caller does not care about the metadata of a specific partitions (as pointed out by Andrew). So it's if not-null, the user cares and we should log it.If
partition != null
, it helps to identify the case of a non-existing partition the user wants to write into. Assume a topic with 4 partitions, and user specific partition 5 as explicit argument when callingsend()
. The producer would try to learn about the leader broker for partition 5, but it does not exist, and it would loop untilmax.block.ms
is exhausted and finally fail with:Partition 5 of topic <FOO> with partition count 4 is not present in metadata after XXX ms.
-- Then we can suspect that the topic may really only have 4 partitions... W/oPartition 5
it's totally unclear why the metadata could not be found and why we hitmax.block.ms
onsend()
; the generic errorTopic %s not present in metadata after %d ms.
does not help us to identify this case.Or did you mean, if
partition == null
? For this case, I agree it's not really helpful to logpartition
(as the user does not care anyway), but it think we don't log it anyway given the current code... (cf below)I believe the code is correct as-is. There is only two cases:
partition == null
. If we get metadata successfully, it implies thatpartitionCount != null
and we just move on and don't throwTimeoutException
. If we cannot get any metadata for the topic, we stay withpartitionCount == null
and useTopic %s not present in metadata after %d ms.
for theTimeoutException
.partition != null
. For this case, if we get metadata successfully, we have apartitionCount
, but we might still fail, if we don't get the metadata for the specified partition. For this case, we would usePartition %d of topic %s with partition count %d is not present in metadata after %d ms
as error message. The other failure case is, that we don't get any metadata for the topic at all, and thuspartitionCount == null
and we still log the right thing. The fact thatpartition != null
does not matter ifpartitionCount == null
.Hence, case (3) is not an error case... If we did get metadata (
partitionCount != null
) and if the user does not care (partition == null
), we will never throwTimeoutException
.