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] Fail a schema-less AUTO_PRODUCE_BYTES send at once instead of retrying it until the send timeout by merlimat · Pull Request #27312 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Motivation

Since #27111, an AUTO_PRODUCE_BYTES producer can register without a schema, and when schema validation is enforced the broker rejects each of its messages that has no schema version. It rejects them with ServerError.MetadataError. Clients treat that code as transient: the Java client's ClientCnx.handleSendError re-registers the producer, which resends the message, and the broker rejects it again. This repeats about every 100 ms until the send timeout (30 s by default) fails the message. Every message queued behind it waits too, and with sendTimeout(0) the producer never recovers.

SimpleSchemaTest.assertAutoProduceBytesRequiresSchemaVersion shows it: in each of the two tests that use it, the producer re-registers about 280 times before the send fails with a TimeoutException.

// The topic has a STRING schema and schema validation is enforced
Producer<byte[]> producer = client.newProducer(Schema.AUTO_PRODUCE_BYTES(Schema.BYTES))
        .topic(topic)
        .enableBatching(false)
        .create();
producer.send(bytes); // resent for 30 s, then TimeoutException

The broker already uses NotAllowedError for permanent per-message publish rejections (max message size, max delivery delay, shadow topics, ended transactions). The Java client has failed just the rejected send on that code since 2.8.0 (ProducerImpl.recoverNotAllowedError, #8732).

Only producers that set the auto_produce_bytes flag (added by #27111) get this check, and only the Java client sets it, so every client that can receive this rejection handles NotAllowedError that way. The C++ (and so Python and Node), Go and Rust clients don't set the flag. The proxy relays send errors unchanged.

Modifications

  • Producer.checkAndStartPublish rejects a message without a schema version from an AUTO_PRODUCE_BYTES producer with NotAllowedError. The client fails that send at once with a NotAllowedException that carries the broker's message, and the producer keeps going.
  • Replicator producers (geo and shadow) still get MetadataError. They have no send timeout, and after a failed send the replicator rewinds and resends right away. With NotAllowedError it resent a rejected message about 7,700 times a second, logging an error each time, instead of re-registering about 10 times a second as now. Their behavior is unchanged.
ServerError error = isRemoteOrShadow ? ServerError.MetadataError : ServerError.NotAllowedError;

A send the broker rejects while earlier messages from the same producer are still being persisted is not failed at once. The Java client matches a NotAllowedError only against the head of its pending queue, as for every other NotAllowedError rejection, so it drops the error. The next receipt then closes the connection, and the resend fails it about 100 ms later. That is client behavior, left for a separate change.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • SimpleSchemaTest.assertAutoProduceBytesRequiresSchemaVersion now expects a NotAllowedException with the broker's message, and the producer's next message, which has a schema, still goes through. Without the fix the test fails after 30 s: "Expected NotAllowedException to be thrown, but TimeoutException was thrown". With it, the two tests that use it take 0.06 s and 0.16 s instead of 30 s each, and the whole class 26 s instead of 85 s.
  • Added ServerCnxTest.testSendWithoutSchemaVersionFromAutoProduceBytesProducer, which checks the error code for a regular producer (NotAllowedError) and a replicator producer (MetadataError). Each case fails if that producer gets the other code.
  • The replicator figures come from a two-cluster replication test, run locally and not included here.

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] Fail a schema-less AUTO_PRODUCE_BYTES send at once inst…
6813008
…ead of retrying it until the send timeout

The broker rejected a message without a schema version from an AUTO_PRODUCE_BYTES producer with
MetadataError, which clients treat as transient: the Java client re-registered the producer and resent
the message about every 100 ms until the send timeout failed it. Reject it with NotAllowedError, which
the Java client, the only client that sets the auto_produce_bytes flag, handles by failing just that send.

Replicator producers keep MetadataError: they have no send timeout and the replicator resends a failed
message at once, so NotAllowedError would make them busy-loop instead of retrying at the reconnection pace.
lhotari
lhotari approved these changes Nov 2, 2026
View reviewed changes
@lhotari lhotari added release/4.2.6 release/4.0.15 release/5.0.2 labels Nov 2, 2026
@merlimat merlimat mentioned this pull request Nov 2, 2026
[fix][broker] Fix replication stuck on a schema-less message to a remote topic with an enforced schema #27314
Merged
11 tasks
@merlimat
merlimat merged commit eb95b84 into apache:master Nov 2, 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
lhotari pushed a commit that referenced this pull request Nov 4, 2026
@merlimat @lhotari
[fix][broker] Fail a schema-less AUTO_PRODUCE_BYTES send at once inst…
efd3dc4
…ead of retrying it until the send timeout (#27312)

(cherry picked from commit eb95b84)
@lhotari lhotari added the cherry-picked/branch-5.0 label 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 cherry-picked/branch-4.0 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@merlimat @lhotari
[fix][broker] Fail a schema-less AUTO_PRODUCE_BYTES send at once inst…
a45caee
…ead of retrying it until the send timeout (apache#27312)

(cherry picked from commit eb95b84)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@merlimat @lhotari
[fix][broker] Fail a schema-less AUTO_PRODUCE_BYTES send at once inst…
67a80f9
…ead of retrying it until the send timeout (apache#27312)

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

Reviewers

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

2 participants

@merlimat @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.