-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
KAFKA-5913: Add hasOffset() and hasTimestamp() methods to RecordMetadata #3878
KAFKA-5913: Add hasOffset() and hasTimestamp() methods to RecordMetadata #3878
Conversation
cc @hachikuji @ijuma I'm open to suggestions for more places where good test cases can be added, if any. |
lgtm |
One thing to think about is that the * @param metadata The metadata for the record that was sent (i.e. the partition and offset).
* If an error occurred, metadata will contain only valid topic and maybe
* partition. If partition is not given in ProducerRecord and an error occurs
* before partition gets assigned, then partition will be set to RecordMetadata.NO_PARTITION.
* The metadata may be null if the client passed null record to
* {@link org.apache.kafka.clients.producer.KafkaProducer#send(ProducerRecord)}.
* @param exception The exception thrown during processing of this record. Null if no error occurred. So, a |
retest this please |
@ijuma that documentation only applies to cases where an error occurred. In the duplicate sequence case, we don't return an error, but don't return the record metadata either. Perhaps a compromise could be that we only raise the This would be complementary to the expectations of the producer interceptor. |
RecordMetadata.offset() and RecordMetadata.timestamp(). Instead we introduce RecordMetadata.hasOffset() and RecordMetadata.hasTimestamp() methods so that applications can determine whether the result of the offset() and timestamp() methods is valid.
@@ -83,7 +83,8 @@ class ProducerFailureHandlingTest extends KafkaServerTestHarness { | |||
} | |||
|
|||
/** | |||
* With ack == 0 the future metadata will have no exceptions with offset -1 | |||
* With ack == 0 we should get a valid record metadata object, but the offset() method should raise | |||
* a RecordMetadataNotAvailableException |
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.
Seems like this needs to be updated.
LGTM. I will merge with a couple trivial cleanups (including the one mentioned by @ijuma). |
We return this exception from
RecordMetadata.offset()
orRecordMetadata.timestamp()
if these pieces of metadata were not returned by the broker.This will happen, for instance, when the broker returns a
DuplicateSequenceException
.