GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][broker] Fix replication stuck on a schema-less message to a remote topic with an enforced schema by merlimat · Pull Request #27314 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Motivation

Since #27111, the geo-replicator's AUTO_PRODUCE_BYTES() producer registers on the remote topic without a schema. When that topic has a schema and schema validation is enforced, the remote broker rejects each message from the producer that has no schema version (Producer.checkAndStartPublish). A message with no schema version on the source topic is replicated without one (ProducerImpl.populateMessageSchema, the hasReplicateFrom() branch). Such messages exist when, for example, they were written before the source topic had a schema, or on a cluster that doesn't enforce validation.

The broker rejects the message with MetadataError, so the replicator's producer re-registers and resends it about 10 times a second. The replicator has no send timeout and keeps order, so neither that message nor any later message on the topic is replicated, and the backlog keeps growing.

// schemaValidationEnforced on both clusters; only the remote topic (r2) has a schema
admin2.topics().createNonPartitionedTopic(topic);
admin2.schemas().createSchema(topic, Schema.STRING.getSchemaInfo());
admin1.topics().createNonPartitionedTopic(topic);
client1.newProducer().topic(topic).create().send(bytes); // never reaches r2

On master, r2's msgInCounter stays at 0 and the replication backlog stays at 1. On #27111's parent the message is replicated. Before #27111 the replicator registered with the remote topic's schema and the broker didn't check each message. #25012 and #25437 made replication work when the remote cluster enforces schema validation, and #27111's own testReplicationOfSchemaLessMessagesWithSchemaValidationEnforced expects schema-less messages to replicate (its remote topic has no schema).

Shadow replication uses the same producer, and a shadow topic reuses its source topic's schema, so it can stall the same way.

Modifications

Producer.checkAndStartPublish no longer applies the schema-version check to replicator producers (geo and shadow, isRemoteOrShadow). They copy messages their source topic already accepted. A replicated message that has a schema still registers it on the remote topic and carries the remote version, as before. Other AUTO_PRODUCE_BYTES producers are still checked.

if (isAutoProduceBytes && requiresSchemaVersion && !isRemoteOrShadow
        && (cnx.getBrokerService().pulsar().getConfig().isSchemaValidationEnforced()
        || topic.getSchemaValidationEnforced())) {

#27312 changes the error code of the same check for other producers and keeps MetadataError for replicators. With this change replicators never reach that rejection, so whichever PR merges second removes that exception and its replicator test case.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Added OneWayReplicatorSchemaValidationEnforcedTest.testReplicationOfSchemaLessMessagesToRemoteTopicWithSchema. It sends a schema-less message on r1, where the topic has no schema, and reads it on r2, where the topic has a STRING schema, with validation enforced on both clusters. Without the fix it fails after its 10 s receive timeout: the message never reaches r2, and in that time the replication client gets 98 MetadataError send errors and its producer re-registers about as often. With the fix it passes in about 1 s, with no send errors. The other three tests in the class still pass.
  • [fix][broker] Support schema-less auto-produce registration #27111's SimpleSchemaTest.autoProduceBytesRequiresSchemaVersion* tests still pass: the broker still rejects messages without a schema version from other AUTO_PRODUCE_BYTES producers.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
[fix][broker] Fix replication stuck on a schema-less message to a rem…
0b997d5
…ote topic with an enforced schema

Since apache#27111 the replicator's AUTO_PRODUCE_BYTES producer registers on the remote topic without a schema.
When that topic has a schema and enforces schema validation, the remote broker rejects every message
without a schema version. A message with no schema version on the source topic is replicated without
one, so the broker rejected it with MetadataError each time: the replicator re-registered and resent it
about 10 times a second, with no send timeout, and nothing after it on the topic was replicated.

Skip the per-message schema-version check for replicator producers (geo and shadow). They copy messages
their source topic already accepted, as before apache#27111. Other AUTO_PRODUCE_BYTES producers are still
checked.
codelipenghui
codelipenghui approved these changes Nov 3, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

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.

LGTM. Reviewed commit 0b997d5.

The new regression test fails with repeated MetadataError rejections when the exemption is removed and passes with the fix restored. Focused geo-replication, ordinary-producer schema enforcement, and shadow tests passed. No actionable findings identified within the reviewed scope.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
merlimat merged commit 00c5732 into apache:master Nov 3, 2026
44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat mentioned this pull request Nov 3, 2026
[fix][test] Fix ServerCnxTest.testSendWithoutSchemaVersionFromAutoProduceBytesProducer failing since #27314 #27331
Merged
11 tasks
merlimat added a commit that referenced this pull request Nov 3, 2026
@merlimat
[fix][test] Fix ServerCnxTest.testSendWithoutSchemaVersionFromAutoPro…
86efc14
…duceBytesProducer failing since #27314 (#27331)
lhotari pushed a commit that referenced this pull request Nov 4, 2026
@merlimat @lhotari
[fix][broker] Fix replication stuck on a schema-less message to a rem…
a113cb0
…ote topic with an enforced schema (#27314)

(cherry picked from commit 00c5732)
lhotari pushed a commit that referenced this pull request Nov 4, 2026
@merlimat @lhotari
[fix][test] Fix ServerCnxTest.testSendWithoutSchemaVersionFromAutoPro…
4722764
…duceBytesProducer failing since #27314 (#27331)

(cherry picked from commit 86efc14)
@lhotari lhotari added release/5.0.2 cherry-picked/branch-5.0 labels Nov 4, 2026
This was referenced Nov 21, 2026
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27680
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27681
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27684
Closed
@lhotari lhotari added cherry-picked/branch-4.2 release/4.2.6 cherry-picked/branch-4.0 release/4.0.15 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@merlimat @lhotari
[fix][broker] Fix replication stuck on a schema-less message to a rem…
13d0ade
…ote topic with an enforced schema (apache#27314)

(cherry picked from commit 00c5732)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@merlimat @lhotari
[fix][test] Fix ServerCnxTest.testSendWithoutSchemaVersionFromAutoPro…
5335881
…duceBytesProducer failing since apache#27314 (apache#27331)

(cherry picked from commit 86efc14)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@merlimat @lhotari
[fix][broker] Fix replication stuck on a schema-less message to a rem…
7f27fa3
…ote topic with an enforced schema (apache#27314)

(cherry picked from commit 00c5732)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@merlimat @lhotari
[fix][test] Fix ServerCnxTest.testSendWithoutSchemaVersionFromAutoPro…
fe7ad8e
…duceBytesProducer failing since apache#27314 (apache#27331)

(cherry picked from commit 86efc14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@codelipenghui codelipenghui codelipenghui approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 cherry-picked/branch-5.0 release/4.0.15 release/4.2.6 release/5.0.2

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@merlimat @codelipenghui @lhotari
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.