[fix][client] Use byte schema for DLQ topic to avoid client side schema validation #21294
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.
Fixes #20635
Motivation
When broker side schema validation is disabled and consumer receives an Avro message that has an incompatible schema then sending messages to DLQ fails due to a client side schema validation. This causes a fast loop that starts creating producers for DLQ topic, consumer gets stuck and explodes the number of producer metrics exposed from broker. Example implementation of this issue.
Modifications
By not inferring the DLQ producer schema from the consumer schema and just producing them as byte schema, this issue is fixed.
Verifying this change
This change is already mostly covered by existing tests, such as
org.apache.pulsar.client.impl.ConsumerImplTest.However, to cover this specific verification edge case
org.apache.pulsar.client.impl.ConsumerImplwould need to refactored to exposepossibleSendToDeadLetterTopicMessagesfor stubbing. Alternatively, a more complicated component test would be needed that would cover the completeConsumerImpl.messageReceived(CommandMessage cmdMessage, ByteBuf headersAndPayload, ClientCnx cnx). This would need to deal with encryption and compression. Did not find an example to base this potential test, so I am not sure what approach to take here.Manually checked that the problem was solved in the constructed example.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: https://github.com/tonisojandu/pulsar