Repository navigation
[fix][broker] Read the producer name of GetOrCreateSchema before authorization completes - #26770
Merged
Merged
Conversation
…orization completes handleGetOrCreateSchema read the producer name from the command inside the callback that runs after the asynchronous topic authorization check. The Pulsar decoder reuses the command object once the handler returns, so by then the fields could belong to a later command on the same connection, and the replicator producer flag passed to addSchema could be wrong. Compute the replicator producer flag before the asynchronous step, and add a test that decodes a second command while the first request is being authorized. Assisted-by: Claude Code
lhotari
requested review from
Technoboy-,
dao-jun,
david-streamlio,
merlimat and
nodece
September 30, 2026 00:38
merlimat
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
ServerCnx#handleGetOrCreateSchemareads the producer name from the command inside the callback that runs after the asynchronous topic authorization check. The Pulsar decoder reuses the command object once the handler returns, so when authorization completes asynchronously, the fields read in the callback can belong to a later command decoded on the same connection. The replicator producer flag passed toTopic#addSchemacan then be wrong.Modifications
Verifying this change
This change added tests and can be verified as follows:
ServerCnxTest#testGetOrCreateSchemaKeepsProducerNameWhileAuthorizing: a replicator producer sendsGetOrCreateSchemawhile its authorization is pending, a secondGetOrCreateSchemawith an ordinary producer name is decoded before authorization completes, and the first request must add the schema with the replicator flag set. The test fails without the fix.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes