[fix][broker] Fix issue with schemaValidationEnforced in geo-replication #25012
+110
−1
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.
Motivation
Geo-replication will fail with
schemaValidationEnforcedenabled in certain cases currently.The replication will be in a loop loggin "IncompatibleSchemaException: Producers cannot connect or send message without a schema to topics with a schemawhen SchemaValidationEnforced is enabled" warnings and errors.
Example logs from the test that reproduces the issue:
The root cause of the problem is in this implementation code in the Pulsar client that geo-replication uses:
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PulsarClientImpl.java
Lines 426 to 443 in c8d6208
After the first lookup for the schema, the schema will be cached. When the schema is missing from the remote cluster's topic, it will always be initialized to
Schema.BYTES. If topic is configured to have a schema, this will get ignored by the replicator since it will continue to useSchema.BYTESfor replication.Modifications
org.apache.pulsar.client.api.Schema#AUTO_PRODUCE_BYTES(org.apache.pulsar.client.api.Schema<?>)method.Documentation
docdoc-requireddoc-not-neededdoc-complete