Skip to content

[Bug] ResourceGroupService requests all topic stats every 60 seconds by default even when it shouldn't be enabled #24693

Closed

Description

@lhotari

Search before reporting

  • I searched in the issues and found nothing similar.

Read release policy

  • I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.

User environment

Potentially all released Pulsar versions that include org.apache.pulsar.broker.resourcegroup.ResourceGroupService, since 2.8.0 . It was part of PIP-82.

Issue Description

The documentation for "resourceUsageTransportPublishIntervalInSecs" states: "Default interval to publish usage reports if resourceUsagePublishToTopic is enabled."

@FieldContext(
dynamic = true,
category = CATEGORY_POLICIES,
doc = "Default interval to publish usage reports if resourceUsagePublishToTopic is enabled."
)
private int resourceUsageTransportPublishIntervalInSecs = 60;

However, the documentation for the configuration setting doesn't make sense since the job to iterate all topic stats happens every 60 seconds:

private void initialize() {
ServiceConfiguration config = this.pulsar.getConfiguration();
long periodInSecs = config.getResourceUsageTransportPublishIntervalInSecs();
this.aggregateLocalUsagePeriodInSeconds = this.resourceUsagePublishPeriodInSeconds = periodInSecs;
this.aggregateLocalUsagePeriodicTask = this.pulsar.getExecutor().scheduleAtFixedRate(
catchingAndLoggingThrowables(this::aggregateResourceGroupLocalUsages),
periodInSecs,
periodInSecs,
this.timeUnitScale);
this.calculateQuotaPeriodicTask = this.pulsar.getExecutor().scheduleAtFixedRate(
catchingAndLoggingThrowables(this::calculateQuotaForAllResourceGroups),
periodInSecs,
periodInSecs,
this.timeUnitScale);
maxIntervalForSuppressingReportsMSecs =
TimeUnit.SECONDS.toMillis(this.resourceUsagePublishPeriodInSeconds) * MaxUsageReportSuppressRounds;
}

protected void aggregateResourceGroupLocalUsages() {
final Summary.Timer aggrUsageTimer = rgUsageAggregationLatency.startTimer();
BrokerService bs = this.pulsar.getBrokerService();
Map<String, TopicStatsImpl> topicStatsMap = bs.getTopicStats();
for (Map.Entry<String, TopicStatsImpl> entry : topicStatsMap.entrySet()) {
final String topicName = entry.getKey();
final TopicStats topicStats = entry.getValue();
final TopicName topic = TopicName.get(topicName);

It would be expected that ResourceGroupService wouldn't perform any activities unless it's used and needed.

Error messages


Reproducing the issue

See the description above.

Additional information

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/bug
    on Sep 2, 2025
  2. Dream95 commented on Sep 23, 2025

    @Dream95
    Contributor

    Hi,I'm currently learning Pulsar. I've noticed that there doesn't seem to be a resourceUsagePublishToTopic config. Can we add a config to resolve this issue? If so, I'm willing to submit a PR.

  3. added a commit that references this issue on Oct 15, 2025
    718f95a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions