Skip to content

[fix][admin] Avoid creating subscriptions when peeking messages if auto-creation is disabled - #26279

Merged
nodece merged 1 commit into
apache:masterfrom
void-ptr974:fix/admin-peek-auto-subscription-policy
Aug 7, 2026
Merged

[fix][admin] Avoid creating subscriptions when peeking messages if auto-creation is disabled#26279
nodece merged 1 commit into
apache:masterfrom
void-ptr974:fix/admin-peek-auto-subscription-policy

Conversation

@void-ptr974

Copy link
Copy Markdown
Contributor

Motivation

The peek messages Admin API implicitly creates a subscription at the earliest position when the requested subscription does not exist. This creation currently bypasses the effective allowAutoSubscriptionCreation policy at the topic, namespace, and broker levels.

As a result, a read-oriented Admin operation can create subscription metadata, retain backlog, and consume subscription quota even when automatic subscription creation is disabled.

Modifications

  • Check the effective automatic subscription creation policy before implicitly creating a subscription for peek messages.
  • Preserve the existing behavior of creating the subscription at the earliest position when automatic creation is allowed.
  • Return HTTP 412 Precondition Failed when the subscription does not exist and automatic creation is disabled.
  • Keep the subscription lookup and creation path asynchronous.
  • Document the REST and Java Admin API behavior.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Extended PersistentTopicsTest.testPeekWithSubscriptionNameNotExist to verify that:
    • peeking does not create a subscription when automatic subscription creation is disabled;
    • the Java Admin client receives PreconditionFailedException;
    • peeking continues to create the subscription and return messages when automatic creation is enabled.
  • Ran the relevant broker and client-admin-api Checkstyle tasks.
  • Compiled the affected broker and client-admin-api modules.

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

  • Dependencies (add or upgrade a dependency)
  • The public API
    • peekMessages now reports PreconditionFailedException when the subscription is missing and automatic creation is disabled.
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
    • The peek message endpoint returns HTTP 412 for the rejected implicit subscription creation.
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

@void-ptr974 void-ptr974 changed the title [fix][admin] Align peek messages with automatic subscription creation policy [fix][admin] Avoid creating subscriptions when peeking messages if auto-creation is disabled Aug 5, 2026
@void-ptr974
void-ptr974 marked this pull request as ready for review August 5, 2026 23:33
@nodece
nodece merged commit 2fbf416 into apache:master Aug 7, 2026
44 of 45 checks passed
lhotari pushed a commit that referenced this pull request Aug 10, 2026
…to-creation is disabled (#26279)

(cherry picked from commit 2fbf416)
lhotari pushed a commit that referenced this pull request Aug 10, 2026
…to-creation is disabled (#26279)

(cherry picked from commit 2fbf416)
@lhotari lhotari added this to the 5.0.0-M2 milestone Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants