Skip to content

[Schema] Fix autoConsumeSchema deadLetter problem. - #9970

Merged
eolivelli merged 7 commits into
apache:masterfrom
congbobo184:congbobo184_fix_auto_consume_schema_problem
Jun 2, 2021
Merged

[Schema] Fix autoConsumeSchema deadLetter problem.#9970
eolivelli merged 7 commits into
apache:masterfrom
congbobo184:congbobo184_fix_auto_consume_schema_problem

Conversation

@congbobo184

Copy link
Copy Markdown
Contributor

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)

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about this version ?
IMHO we should delegate to the wrapped schema

@Override
    public SchemaInfo getSchemaInfo() {
        ensureSchemaInitialized();

        return schema.getSchemaInfo();
    }

@congbobo184

Copy link
Copy Markdown
Contributor Author

@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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't is better to consistently return an error if schemaVersion is null ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good idea

return this.schema;
}

public CompletableFuture<Schema<?>> getOriginalSchema() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are we changing PulsarSink ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PulsarSink use MessageImpl.getSchema()

return;
}

if (!populateMessageSchema(msg, callback)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it necessary to change ProducerImpl ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as above.

}

default Schema<T> getSchema() {
default Schema getSchema() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are we removing this template parameter ?
it is wrong, if the Record is of type T, than the Schema is for type T

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we need to change PulsarSource ?

@codelipenghui codelipenghui added this to the 2.8.0 milestone Apr 2, 2021
@codelipenghui codelipenghui modified the milestones: 2.8.0, 2.9.0 May 21, 2021
# 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
@congbobo184

Copy link
Copy Markdown
Contributor Author

@eolivelli please review again thanks.

@congbobo184 congbobo184 added the type/bug The PR fixed a bug or issue reported a bug label Jun 2, 2021

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great!
I am happy the getReaderSchema helped to fix this problem

@eolivelli
eolivelli merged commit 9b28bf3 into apache:master Jun 2, 2021
@congbobo184 congbobo184 modified the milestones: 2.9.0, 2.8.0 Jun 2, 2021
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
* [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>
315157973 pushed a commit that referenced this pull request Feb 22, 2022
…14317)

If a message reached maxRedeliverCount, it will send to deadLetterTopic, since 2.8.0, this mechanism is broken, it was introduced in #9970
michaeljmarshall pushed a commit that referenced this pull request Feb 24, 2022
…14317)

If a message reached maxRedeliverCount, it will send to deadLetterTopic, since 2.8.0, this mechanism is broken, it was introduced in #9970

(cherry picked from commit 16beb9d)
codelipenghui pushed a commit that referenced this pull request Feb 25, 2022
…14317)

If a message reached maxRedeliverCount, it will send to deadLetterTopic, since 2.8.0, this mechanism is broken, it was introduced in #9970

(cherry picked from commit 16beb9d)
List<MessageImpl<T>> finalDeadLetterMessages = deadLetterMessages;
MessageIdImpl finalMessageId = messageId;
deadLetterProducer.thenAccept(producerDLQ -> {
deadLetterProducer.thenAcceptAsync(producerDLQ -> {

@mattisonchao mattisonchao Mar 1, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@congbobo184 Why do we use a common pool to run the next logic?

nicoloboschi pushed a commit to nicoloboschi/pulsar that referenced this pull request Mar 1, 2022
…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
gaoran10 pushed a commit that referenced this pull request Mar 1, 2022
…14317)

If a message reached maxRedeliverCount, it will send to deadLetterTopic, since 2.8.0, this mechanism is broken, it was introduced in #9970

(cherry picked from commit 16beb9d)
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
* [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>
@congbobo184
congbobo184 deleted the congbobo184_fix_auto_consume_schema_problem branch March 24, 2022 04:58
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead letter producer does not handle AUTO_CONSUME_SCHEMA

4 participants