Skip to content

[fix][broker] Read subscription properties directly from cursor#26159

Merged
nodece merged 2 commits into
apache:masterfrom
nodece:fix/subscription-properties-live-cursor
Jul 9, 2026
Merged

[fix][broker] Read subscription properties directly from cursor#26159
nodece merged 2 commits into
apache:masterfrom
nodece:fix/subscription-properties-live-cursor

Conversation

@nodece

@nodece nodece commented Jul 7, 2026

Copy link
Copy Markdown
Member

Motivation

PersistentSubscription.subscriptionProperties stores a cached snapshot initialized on construction, and can only be refreshed via updateSubscriptionProperties.

Other components write properties directly using ManagedCursor.putCursorProperty, especially the #pulsar.internal.delayed.bucket_* keys generated by the delayed message bucket tracker, but these changes will not sync to the local cache.

This leads to stale data returned by:

  • org.apache.pulsar.client.admin.Topics#getSubscriptionProperties
  • org.apache.pulsar.client.admin.Topics#getStats(java.lang.String, org.apache.pulsar.client.admin.GetStatsOptions)

The cache can only reload the latest data from cursor.getCursorProperties() after broker restart.

Modifications

  • Remove cached subscriptionProperties field, use cursor as the single source of truth for properties.
  • Modify getSubscriptionProperties() to directly return cursor.getCursorProperties(), so admin interfaces and PersistentSubscription.getStatsAsync can read real-time data.
  • Simplify updateSubscriptionProperties to one single cursor.setCursorProperties(...) call, no extra cache field synchronization required.
  • Deprecate the constructor overload with subscriptionProperties parameter. This unused parameter will be deleted in a subsequent PR after cleaning all relevant callsites in PersistentTopic.
  • Add unit test PersistentSubscriptionTest#testGetSubscriptionPropertiesReflectsLiveCursorUpdates to verify real-time property visibility for both getSubscriptionProperties() and stats logic.

@nodece nodece closed this Jul 9, 2026
@nodece nodece reopened this Jul 9, 2026
@nodece nodece merged commit 803ff96 into apache:master Jul 9, 2026
46 checks passed
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.

3 participants