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 — [improve][broker] Recover incompatible replication schemas on metadata changes by poorbarcode · Pull Request #27033 · apache/pulsar

Conversation

@poorbarcode

@poorbarcode poorbarcode commented Oct 21, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Motivation

An incompatible replication schema is normally a stable destination-broker condition: submitting the same schema registration again cannot succeed until an operator changes schema compatibility policy or schema metadata. Client-side delayed retries continue to issue GetOrCreateSchema requests while that condition is unchanged, and they keep retry lifecycle state in the client producer for a condition whose resolution is controlled by the destination broker.

The destination broker already observes the three events that can make a blocked incompatible schema worth retrying: an effective topic or namespace schema-compatibility change, an actual new schema version, and schema deletion. Using these events as the recovery trigger makes the retry immediate when destination metadata changes, avoids polling while it does not, and keeps the decision next to the state that determines compatibility. The producer reconnect path then performs the ordinary schema registration flow against the new broker metadata.

Modifications

  • Recovery is initiated only by destination metadata changes that can affect schema compatibility, avoiding timer-driven GetOrCreateSchema polling while the condition is unchanged.
  • The destination broker records exactly which remote replication producer was rejected for an incompatible schema, so unrelated producers remain connected.
  • A relevant policy or schema event disconnects that blocked producer and reuses the established reconnect and schema-registration path.
  • In-progress registrations are observed before disconnecting, preventing a metadata event from missing a just-completed incompatible result.
  • The change removes the incompatible-schema delayed retry path from the client while leaving ordinary reconnect behavior intact.

ServerCnx installs a completion marker before it starts schema registration and captures the producer name before the decoded command can be reused. If an incompatible response belongs to a replication producer, it marks the matching remote producer as blocked before completing the marker. Topics wait for the current marker snapshot, then disconnect only blocked remote producers when their effective schema compatibility strategy changes. Schema registration reports whether it created a version, allowing topic and REST paths to notify only on actual creation; successful schema deletion also notifies a loaded topic. Persistent and non-persistent topics both handle policy changes.

The client-side delayed retry implementation and its timer-specific tests are removed. The broker E2E coverage exercises topic-policy, namespace-policy, compatible-schema-creation, and schema-deletion events with deduplication enabled and disabled; it verifies reconnect, backlog drain, and ordered delivery after compatibility is restored.

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

  • 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
@poorbarcode poorbarcode self-assigned this Oct 21, 2026
@poorbarcode poorbarcode added release/4.2.6 release/4.0.15 labels Oct 21, 2026
@poorbarcode poorbarcode added this to the 5.1.0 milestone Oct 21, 2026
@poorbarcode poorbarcode added the release/5.0.1 label Oct 21, 2026
@poorbarcode
poorbarcode requested review from codelipenghui and lhotari October 21, 2026 16:07
@poorbarcode poorbarcode changed the title [fix][broker] Recover replication after incompatible schema changes [improve][broker] Recover incompatible replication schemas on metadata changes Oct 21, 2026
lhotari
lhotari reviewed Oct 21, 2026
View reviewed changes
Comment thread pulsar-client/src/test/java/org/apache/pulsar/client/impl/ProducerImplTest.java Resolved

Uh oh!

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

@poorbarcode
poorbarcode requested a review from lhotari October 21, 2026 18:28
lhotari
lhotari requested changes Oct 21, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

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.

Thanks for working on a broker-driven recovery for blocked replication producers; moving the decision next to the metadata that determines compatibility is a sound direction, and the marker/flag ordering in ServerCnx and AbstractTopic looks right to me.

My main concern is that the ProducerImpl change is not only the removal of the incompatible-schema delayed retry: the client files are byte-identical to the state before #27026, so the backoff for other registration errors and the stale-response guards that #27026 added go away too. I ran the ProducerImplTest from before this PR against the new ProducerImpl: 17 of 59 tests fail, including testSchemaRegistrationErrorsUseBackoff, testUnsupportedSchemaProtocolUsesBackoff, testSchemaResponseAfterCloseIsIgnored, testSchemaResponseRecoversAfterPendingMessageFails and testStaleSchemaResponseCannotInterruptAnotherRegistration. If the intent is to drop only the incompatible-schema polling, I would keep those guards and tests and remove just the retry path. If the full revert is intended, the PR description should say so, and the concerns below need an answer.

Separately, a few recovery triggers are missing (partitioned topics through the REST path, enabling schema auto-update), and a new client against an older destination broker no longer recovers automatically; a slow client-side fallback would cover the missed-trigger cases too. Details are inline.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java Resolved

Uh oh!

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

Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java Resolved

Uh oh!

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

Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java Resolved

Uh oh!

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

Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java Resolved

Uh oh!

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

Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java Resolved

Uh oh!

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

Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java Resolved

Uh oh!

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

Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java Resolved

Uh oh!

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

Comment thread pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorTest.java Resolved

Uh oh!

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

@poorbarcode
poorbarcode requested a review from lhotari October 22, 2026 10:01
lhotari
lhotari requested changes Oct 22, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

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.

Thanks for the quick follow-ups: restoring the backoff, the generation/connection/identity guards and the DEBUG logs, the new try/catch in ServerCnx, the topic-policy deletion trigger and the test cleanup fix address most of my earlier points, and CI is green now.

One blocking point remains: a replication producer whose schema is still incompatible after the broker-driven reconnect re-registers in a loop without backoff, because the old Broken guard went away (details inline). The REST notification also only reaches partitions loaded on the broker that served the request. The remaining threads have replies below.

A side note on 9feb7f7: onUpdate(null) now clears the live topic policies on deletion for every policy, not just the schema ones (before, a deleted topic policy stayed in effect until the topic was reloaded). That looks like a correct general fix, but since it changes behaviour beyond schema recovery it would be worth a line in the PR description.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java Resolved

Uh oh!

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

Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/SchemasResourceBase.java Resolved

Uh oh!

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

Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java Resolved

Uh oh!

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

Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java Resolved

Uh oh!

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

@poorbarcode poorbarcode mentioned this pull request Oct 22, 2026
[Bug][broker] Replication recovery can restore a deleted remote schema #27048
Closed
@poorbarcode
poorbarcode requested a review from lhotari October 22, 2026 18:22
poorbarcode added 15 commits October 23, 2026 10:36
@poorbarcode
[fix][broker] Recover replication after incompatible schema changes
d8a45a3
@poorbarcode
[improve][broker] Fix schema recovery import order
8ed3606
@poorbarcode
[test][client] Restore incompatible schema regression test
078d5c5
@poorbarcode
[fix][broker] Harden schema recovery registration flow
2e7939f
@poorbarcode
[fix][broker] Recover replication after topic policy deletion
52b50aa
@poorbarcode
[test][broker] Verify shadow replication schema reuse
c4cc6cd
@poorbarcode
[test][broker] Clean up partitioned replication recovery topic
f4fb078
@poorbarcode
[test][broker] Fix shadow schema test formatting
0758efc
@poorbarcode
[fix][broker] Recover replication after schema metadata changes
94e84d7
@poorbarcode
[improve][broker] Document schema registration topic methods
345c7ae
@poorbarcode
[test][broker] Track schema deletion recovery issue
caeadaa
@poorbarcode
improve code
6a61cea
@poorbarcode
[test][broker] Stabilize global schema policy recovery test
cf2cefb
@poorbarcode
[test][broker] Wait for deduplication ledger trimming
b9232b1
@poorbarcode
Revert "[fix][broker] Recover replication after topic policy deletion"
6162306
poorbarcode added 7 commits October 23, 2026 10:36
@poorbarcode
Revert "[test][broker] Stabilize global schema policy recovery test"
a798d1f
@poorbarcode
[cleanup][broker] Remove unused schema registration result
1f912dd
@poorbarcode
[fix][broker] Remove unused schema registry imports
3e62b8d
@poorbarcode
disable test testReplicationResumesAfterDeletingIncompatibleSchema
513c6ec
@poorbarcode
disable test testReplicationResumesAfterDeletingIncompatibleSchema
022aa83
@poorbarcode
remove unnecessary changes
43913a1
@poorbarcode
remove unnecessary changes
3bfc411
@poorbarcode
poorbarcode force-pushed the improve_27026 branch from 8177bb8 to 3bfc411 Compare October 23, 2026 02:36
@poorbarcode poorbarcode added the ready-to-test label Oct 23, 2026
@lhotari lhotari added release/5.0.2 and removed release/5.0.1 labels Oct 23, 2026
Denovo1998
Denovo1998 requested changes Oct 27, 2026
View reviewed changes
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Comment on lines +3953 to +3959
schemaVersionFuture.whenComplete((schemaVersion, ex) -> {
topic.completeInProgressSchemaRegistrationMarker(inProgressSchemaRegistrationMarker);
if (ex != null) {
Throwable actEx = FutureUtil.unwrapCompletionException(ex);
if (isReplicatorProducer && actEx instanceof IncompatibleSchemaException) {
topic.markProducerBlockedByIncompatibleSchema(producerName);
}

@Denovo1998 Denovo1998 Oct 27, 2026

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.

Could we mark the replication producer as blocked before completing the registration marker?

complete() can synchronously run the waitForAll(...).handle(...) callback in AbstractTopic. If a metadata change is already waiting for this registration, the callback may check the producer before markProducerBlockedByIncompatibleSchema() runs, miss the disconnect, and leave replication paused until another metadata change occurs.

Completing the marker after updating the blocked state would avoid this race.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Comment on lines -3949 to +3953
ServerError errorCode = BrokerServiceException.getClientErrorCode(ex);
String message = ex.getMessage();
if (ex.getCause() != null) {
message += (" caused by " + ex.getCause());
schemaVersionFuture.whenComplete((schemaVersion, ex) -> {

@Denovo1998 Denovo1998 Oct 27, 2026

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.

It looks like the latest commit removed the synchronous-exception guard added in 424088082e.

If tryAddSchema() throws before returning a future, the registration marker is never completed or removed. Subsequent metadata-change recovery will then wait indefinitely on that marker.

Could we restore the try/catch (or otherwise guarantee marker completion on synchronous failures)? This seems to reintroduce the issue raised in the earlier review.

Sorry, something went wrong.

Uh oh!

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

All reactions
@poorbarcode poorbarcode mentioned this pull request Nov 13, 2026
[fix][broker] Support schema-less auto-produce registration #27111
Merged
lhotari
lhotari requested changes Nov 19, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

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.

Thanks for narrowing the scope in this round. Restoring the consumer-side delivery and ordering assertions in the recovery test is a good outcome, and dropping the created flag simplifies the schema registry changes.

Two points from this round are blocking. First, the GetOrCreateSchema handler in ServerCnx now completes the in-progress registration marker before it marks the replication producer as blocked, and the cleanup also dropped the guard for a synchronous failure of tryAddSchema. I read the code the same way as the two comments from Denovo1998 on those lines (order, guard); in short: a metadata change that is already waiting on the marker runs its disconnect pass synchronously inside complete() (AbstractTopic.disconnectProducersBlockedByIncompatibleSchema uses waitForAll(...).handle(...)), so it can run before the producer is marked and miss it, and a synchronous throw from tryAddSchema now leaves the marker registered forever, which makes every later disconnect pass on that topic wait for it. Marking before completing, and completing in a finally-style path for the synchronous failure, restores what the previous revision did; a ServerCnxTest with a real marker would pin the order, since the current test mocks Topic. Second, the paused-producer return in ProducerImpl also fires for the retry after a transient registration failure, which leaves the replication producer stuck with nothing to wake it (inline).

Smaller points: the reconnect test can still race the first rejection, and #27048, which the disabled delete-schema variants wait on, is now closed by #27111 on master, so those variants can come back once the branch is merged with master. The branch conflicts with master in BrokerService, ServerCnx and ProducerImplTest, so a merge is needed anyway. Please also refresh the PR description: it still mentions the created flag, REST/topic-level schema notifications and a delete-schema E2E, and it does not mention that topic-policy removal no longer triggers recovery.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ProducerImpl.java
tryRegisterSchema(cnx, loopEndDueToSchemaRegisterNeeded, expectedEpoch);
} else if (failedIncompatibleSchema && pauseSendingToPreservePublishOrderOnSchemaRegFailure) {
// The registration failure handler schedules the retry, keeping subsequent messages queued.
} else if (pauseSendingToPreservePublishOrderOnSchemaRegFailure

@lhotari lhotari Nov 19, 2026

Copy link
Copy Markdown
Member

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.

[BUG] A transient GetOrCreateSchema failure after the broker-driven reconnect leaves the replication producer stuck

Thanks for fixing the re-registration loop. This branch is now also taken for the delayed retry of a failure that is not an incompatible schema:

  1. The broker disconnects the blocked producer, the producer reconnects, and tryRegisterSchema runs for the still-Broken message (Connecting -> Ready, then RegisteringSchema).
  2. GetOrCreateSchema fails with a transient error (timeout, NotSupported). The callback in ProducerImpl.java:1053-1066 schedules recoverProcessOpSendMsgFrom(cnx, msg, false, ...).
  3. The loop meets the Broken message at ProducerImpl.java:2988-2993 and breaks, the state is RegisteringSchema, and this branch returns. Nothing retries again, and replication has no send timeout, so the producer stays stuck.
  4. The broker only marks a replication producer as blocked for an IncompatibleSchemaException (ServerCnx.java:3957-3959), so the new registration is unmarked and no schema or policy change will disconnect it.

Before this change that retry reached the RegisteringSchema -> Ready branch below and registered again. Gating the return on the failedIncompatibleSchema argument keeps the pause for incompatible callbacks (they pass true) and lets the backoff retry (false) fall through to re-registration, without bringing the loop back. A ProducerImplTest with conf.setReplProducer(true) would pin it: first request incompatible, reconnect, second request fails with a generic error, and a third request is sent after the backoff.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorTest.java
producer.newMessage(schema).value(new KeyValue<>(
incompatibleKey.newRecordBuilder().set("game_id", 1L).build(), "game")).send();
Awaitility.await().untilAsserted(() ->
assertThat(replicator.getCursor().getNumberOfEntriesInBacklog(false)).isOne());

@lhotari lhotari Nov 19, 2026

Copy link
Copy Markdown
Member

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.

[SUGGESTION] A source backlog of one does not show the destination has already rejected the producer

If the replicator's first GetOrCreateSchema reaches the destination after the createSchema further down, the producer is marked blocked with no notification left to wake it and the epoch wait times out; if it arrives after the appender is installed but before the change, the exact-one request count fails. Waiting for the first rejection before changing the schema (for example the destination topic's remote producer reporting blocked, or the rejected request being logged) would make the sequence deterministic.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/test/java/org/apache/pulsar/broker/service/OneWayReplicatorTest.java
{true, SchemaRecoveryTrigger.NAMESPACE_POLICY},
{false, SchemaRecoveryTrigger.NEW_SCHEMA},
{true, SchemaRecoveryTrigger.NEW_SCHEMA}
// TODO: Re-enable after https://github.com/apache/pulsar/issues/27048 is fixed.

@lhotari lhotari Nov 19, 2026

Copy link
Copy Markdown
Member

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.

[SUGGESTION] The delete-schema variants can be re-enabled after merging master

#27048 is closed: #27111 (merged to master on 2026-10-30) stops an AUTO_PRODUCE_BYTES producer from re-registering its cached schema on reconnect when the broker supports it, which is the cause you identified. Once this branch is merged with master, could the DELETE_SCHEMA rows here be re-enabled and the TODO removed? That also gives the Deleted notification handling in BrokerService.handleMetadataChanges a test again; at this head nothing exercises it. Please also link a tracking issue from the @Test(enabled = false) on testReplicationResumesAfterRemovingTopicPolicies, since the comment there says the topic-policy removal recovery is tracked separately but names nothing.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
ServerError errorCode = BrokerServiceException.getClientErrorCode(actEx);
String message = actEx.getMessage();
if (ex.getCause() != null) {
message += (" caused by " + actEx.getCause());

@lhotari lhotari Nov 19, 2026

Copy link
Copy Markdown
Member

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.

[NIT] The error text checks one exception and appends another

The guard tests ex.getCause() but the text appends actEx.getCause(). For a CompletionException wrapping an exception without a cause, the guard passes and the client receives ... caused by null. Using actEx in both places (or ex in both, as the previous revision did) avoids it.

Sorry, something went wrong.

Uh oh!

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

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari requested changes
@Denovo1998 Denovo1998 Denovo1998 requested changes
@codelipenghui codelipenghui Awaiting requested review from codelipenghui

Requested changes must be addressed to merge this pull request.

Uh oh!

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

Assignees

@poorbarcode poorbarcode

Labels

ready-to-test release/4.0.15 release/4.2.6 release/5.0.2

Projects

None yet

Milestone

5.1.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@poorbarcode @lhotari @Denovo1998
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.