[Schema] Fix autoConsumeSchema deadLetter problem. - #9970
Conversation
eolivelli
left a comment
There was a problem hiding this comment.
awesome work @congbobo184
I see that this new class is very similar to AutoProduceBytesSchema
is there a way to consolidate the logic in a common base class
|
|
||
| @Override | ||
| public SchemaInfo getSchemaInfo() { | ||
| return BytesSchema.of().getSchemaInfo(); |
There was a problem hiding this comment.
what about this version ?
IMHO we should delegate to the wrapped schema
@Override
public SchemaInfo getSchemaInfo() {
ensureSchemaInitialized();
return schema.getSchemaInfo();
}
|
@eolivelli thanks for you comment, I change the deadLetterProducer to AutoProduceBytesSchema. please review again. |
| public CompletableFuture<SchemaInfo> getSchemaInfo(byte[] schemaVersion) { | ||
| ensureSchemaInitialized(); | ||
| if (schema.supportSchemaVersioning()) { | ||
| if (schemaVersion == null) { |
There was a problem hiding this comment.
isn't is better to consistently return an error if schemaVersion is null ?
| return this.schema; | ||
| } | ||
|
|
||
| public CompletableFuture<Schema<?>> getOriginalSchema() { |
There was a problem hiding this comment.
can you please add a javadoc that explains why method returns a CompletableFuture ?
for instance we could need to download the schema from the network.
can we name this method "fetchSchema" ?
This way the name itself reads that this is not a simple "getter" but that the operation may perform additional operations.
eolivelli
left a comment
There was a problem hiding this comment.
are you sure that you are not adding another patch on top of this patch ?
I see changed related to Pulsar IO and also to PulsarProducer that look unrelated
| @@ -88,15 +88,17 @@ public class PulsarSink<T> implements Sink<T> { | |||
|
|
|||
| private interface PulsarSinkProcessor<T> { | |||
There was a problem hiding this comment.
why are we changing PulsarSink ?
There was a problem hiding this comment.
PulsarSink use MessageImpl.getSchema()
| return; | ||
| } | ||
|
|
||
| if (!populateMessageSchema(msg, callback)) { |
There was a problem hiding this comment.
is it necessary to change ProducerImpl ?
| } | ||
|
|
||
| default Schema<T> getSchema() { | ||
| default Schema getSchema() { |
There was a problem hiding this comment.
why are we removing this template parameter ?
it is wrong, if the Record is of type T, than the Schema is for type T
There was a problem hiding this comment.
i will change it.
| @@ -128,31 +130,43 @@ public void open(Map<String, Object> config, SourceContext sourceContext) throws | |||
|
|
|||
| @Override | |||
| public void received(Consumer<T> consumer, Message<T> message) { | |||
There was a problem hiding this comment.
why do we need to change PulsarSource ?
# Conflicts: # pulsar-broker/src/test/java/org/apache/pulsar/client/api/DeadLetterTopicTest.java # pulsar-broker/src/test/java/org/apache/pulsar/client/api/InterceptorsTest.java # pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Schema.java # pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java # pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageImpl.java # pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java # pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AbstractStructSchema.java # pulsar-client/src/main/java/org/apache/pulsar/client/impl/schema/AutoConsumeSchema.java # pulsar-common/src/main/java/org/apache/pulsar/common/protocol/schema/SchemaHash.java # pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/source/PulsarSource.java # pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/sink/PulsarSinkTest.java # pulsar-functions/instance/src/test/java/org/apache/pulsar/functions/source/PulsarSourceTest.java
|
@eolivelli please review again thanks. |
eolivelli
left a comment
There was a problem hiding this comment.
Great!
I am happy the getReaderSchema helped to fix this problem
* [Schema] Fix autoConsumeSchema deadLetter problem. * Change the schema to AutoProduceBytesSchema * Fix the message getSchemaInfo * add message getOriginalSchema * Change message getSchema method to async * Fix the test Co-authored-by: congbo <congbobo184@github.com>
| List<MessageImpl<T>> finalDeadLetterMessages = deadLetterMessages; | ||
| MessageIdImpl finalMessageId = messageId; | ||
| deadLetterProducer.thenAccept(producerDLQ -> { | ||
| deadLetterProducer.thenAcceptAsync(producerDLQ -> { |
There was a problem hiding this comment.
@congbobo184 Why do we use a common pool to run the next logic?
…pache#14317) If a message reached maxRedeliverCount, it will send to deadLetterTopic, since 2.8.0, this mechanism is broken, it was introduced in apache#9970
* [Schema] Fix autoConsumeSchema deadLetter problem. * Change the schema to AutoProduceBytesSchema * Fix the message getSchemaInfo * add message getOriginalSchema * Change message getSchema method to async * Fix the test Co-authored-by: congbo <congbobo184@github.com>
…pache#14317) If a message reached maxRedeliverCount, it will send to deadLetterTopic, since 2.8.0, this mechanism is broken, it was introduced in apache#9970
Motivation
in order to fix autoConsumeSchema deadLetter problem.
fix #9935
implement
Add AutoProduceSchema to fix it
Verifying this change
Add the tests for it
Does this pull request potentially affect one of the following parts:
If yes was chosen, please highlight the changes
Dependencies (does it add or upgrade a dependency): (no)
The public API: (no)
The schema: (no)
The default values of configurations: (no)
The wire protocol: (no)
The rest endpoints: (no)
The admin cli options: (no)
Anything that affects deployment: (no)