GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [improve][broker] Recover incompatible replication schemas on metadata changes by poorbarcode · Pull Request #27033 · apache/pulsar Conversation
|
| schemaVersionFuture.whenComplete((schemaVersion, ex) -> { | ||
| topic.completeInProgressSchemaRegistrationMarker(inProgressSchemaRegistrationMarker); | ||
| if (ex != null) { | ||
| Throwable actEx = FutureUtil.unwrapCompletionException(ex); | ||
| if (isReplicatorProducer && actEx instanceof IncompatibleSchemaException) { | ||
| topic.markProducerBlockedByIncompatibleSchema(producerName); | ||
| } |
There was a problem 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.
There was an error while loading. Please reload this page.
| ServerError errorCode = BrokerServiceException.getClientErrorCode(ex); | ||
| String message = ex.getMessage(); | ||
| if (ex.getCause() != null) { | ||
| message += (" caused by " + ex.getCause()); | ||
| schemaVersionFuture.whenComplete((schemaVersion, ex) -> { |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| tryRegisterSchema(cnx, loopEndDueToSchemaRegisterNeeded, expectedEpoch); | ||
| } else if (failedIncompatibleSchema && pauseSendingToPreservePublishOrderOnSchemaRegFailure) { | ||
| // The registration failure handler schedules the retry, keeping subsequent messages queued. | ||
| } else if (pauseSendingToPreservePublishOrderOnSchemaRegFailure |
There was a problem 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:
tryRegisterSchema runs for the still-Broken message (Connecting -> Ready, then RegisteringSchema).GetOrCreateSchema fails with a transient error (timeout, NotSupported). The callback in ProducerImpl.java:1053-1066 schedules recoverProcessOpSendMsgFrom(cnx, msg, false, ...).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.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.
There was an error while loading. Please reload this page.
| producer.newMessage(schema).value(new KeyValue<>( | ||
| incompatibleKey.newRecordBuilder().set("game_id", 1L).build(), "game")).send(); | ||
| Awaitility.await().untilAsserted(() -> | ||
| assertThat(replicator.getCursor().getNumberOfEntriesInBacklog(false)).isOne()); |
There was a problem 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.
There was an error while loading. Please reload this page.
| {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. |
There was a problem 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.
There was an error while loading. Please reload this page.
| ServerError errorCode = BrokerServiceException.getClientErrorCode(actEx); | ||
| String message = actEx.getMessage(); | ||
| if (ex.getCause() != null) { | ||
| message += (" caused by " + actEx.getCause()); |
There was a problem 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.
There was an error while loading. Please reload this page.
Requested changes must be addressed to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.