You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/07 17:49:09 UTC
[GitHub] [pulsar] heesung-sn opened a new pull request, #18807: [fix][metrics] fixed a partitioned publisher topic stat aggregation bug
heesung-sn opened a new pull request, #18807:
URL: https://github.com/apache/pulsar/pull/18807
<!--
### Contribution Checklist
- PR title format should be *[type][component] summary*. For details, see *[Guideline - Pulsar PR Naming Convention](https://docs.google.com/document/d/1d8Pw6ZbWk-_pCKdOmdvx9rnhPiyuxwq60_TrD68d7BA/edit#heading=h.trs9rsex3xom)*.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
-->
### Motivation
The index-based publisher stat aggregation(configured by `aggregatePublisherStatsByProducerName`=false, default, triggered by `pulsar-admin topics partitioned-stats api`) can burst memory and wrongly aggregate publisher metrics if each partition stat returns a different size or order of the publisher stat list.
In the worst case, if there are many partitions and publishers created and closed concurrently, the current code can create PublisherStatsImpl objects exponentially, and this can cause a high GC time or OOM.
Discussion Thread:
https://lists.apache.org/thread/vofv1oz0wvzlwk4x9vk067rhkscn8bqo
Issue Code reference:
https://github.com/apache/pulsar/commit/2c428f7fcc740525e8120566c0272fc863ffebf1#diff-02e50674125a597f8ae3405a884590759f2fdaa10104cea511d5ea44b6ff6490R224-R247
<!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
### Modifications
- Fixed the bug code (the nested loop) that could exponentially create PublisherStatsImpl objects.
- Updated the aggregatePublisherStatsByProducerName config default to `true`.
<!-- Describe the modifications you've done. -->
### Verifying this change
- [x] Make sure that the change passes the CI checks.
This change added unit tests.
### 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
- [x] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] Anything that affects deployment
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
- [] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: https://github.com/heesung-sn/pulsar/pull/15
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on pull request #18807: [fix][monitor] Fix the partitioned publisher topic stat aggregation bug
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#issuecomment-1537483222
@heesung-sn
I have add the label `[release/2.10.5, release/2.11.2]` and cherry-picked this patch to there branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] equanz commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
equanz commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1058656380
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
> Do you mean we need to comment that PartitionedTopicStatsImpl is not thread-safe?
Yes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] equanz commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
equanz commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1049476590
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
nits:
The `publishers` field is not thread-safe from before. Potentially access to it from concurrent threads.
Moreover, it doesn't guarantee the size is `index + 1` in L262 because it isn't held mutual lock between L259 and L262.
https://github.com/apache/pulsar/blob/1107af24932e5703209f1e1e896953328ce3ddaa/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java#L111
https://github.com/apache/pulsar/blob/1107af24932e5703209f1e1e896953328ce3ddaa/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java#L179
We want to avoid IndexOutOfBoundsException completely.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1058648847
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
Hi, sorry. Do you mean we need to comment that `PartitionedTopicStatsImpl` is not thread-safe?
Otherwise, PTAL again (or could you approve this too?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1058648847
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
Hi, sorry. Do you mean we need to comment that `PartitionedTopicStatsImpl` is not thread-safe?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1059498810
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/NonPersistentTopicStatsImpl.java:
##########
@@ -165,20 +166,15 @@ public NonPersistentTopicStatsImpl add(NonPersistentTopicStats ts) {
return newStats;
})).add((NonPersistentPublisherStatsImpl) s);
} else {
- if (this.nonPersistentPublishers.size() != stats.getNonPersistentPublishers().size()) {
- for (int i = 0; i < stats.getNonPersistentPublishers().size(); i++) {
- NonPersistentPublisherStatsImpl newStats = new NonPersistentPublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.nonPersistentPublishers.add(newStats.add((NonPersistentPublisherStatsImpl) s));
- }
- } else {
- for (int i = 0; i < stats.getNonPersistentPublishers().size(); i++) {
- ((NonPersistentPublisherStatsImpl) this.nonPersistentPublishers.get(i))
- .add((NonPersistentPublisherStatsImpl) s);
- }
+ if (index == this.nonPersistentPublishers.size()) {
+ NonPersistentPublisherStatsImpl newStats = new NonPersistentPublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.nonPersistentPublishers.add(newStats);
Review Comment:
Added comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1058648847
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
Hi, sorry. Do you mean we need to comment that `PartitionedTopicStatsImpl` is not thread-safe?
Otherwise, PTAL again (or could you approve this?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Technoboy- closed pull request #18807: [fix][metrics] fixed a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
Technoboy- closed pull request #18807: [fix][metrics] fixed a partitioned publisher topic stat aggregation bug
URL: https://github.com/apache/pulsar/pull/18807
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui closed pull request #18807: [fix][monitor] Fix the partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
codelipenghui closed pull request #18807: [fix][monitor] Fix the partitioned publisher topic stat aggregation bug
URL: https://github.com/apache/pulsar/pull/18807
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] equanz commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
equanz commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1051389466
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
This case may not be in the current codes. If contributors already know "the caller needs to externally synchronize the access," we don't care in this section. I'm worried about misimplementation. So, I think it's okay to write comments about the current spec instead of fixing it to follow my comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1058683946
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
Added comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#issuecomment-1368061496
> Is it better to split it into 2 PRs? One is to fix the aggregation issue, another change the default value.
>
> So that we can ship the fix to release branches, and the default configuration change only applies to the master branch (release in the next major version).
I reverted the config default change in this PR.
I raised another PR for the config default change here. https://github.com/apache/pulsar/pull/19114
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1050174671
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/TopicStatsImpl.java:
##########
@@ -252,19 +253,15 @@ public TopicStatsImpl add(TopicStats ts) {
return newStats;
}).add((PublisherStatsImpl) s);
} else {
- if (this.publishers.size() != stats.publishers.size()) {
- for (int i = 0; i < stats.publishers.size(); i++) {
- PublisherStatsImpl newStats = new PublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.publishers.add(newStats.add(stats.publishers.get(i)));
- }
- } else {
- for (int i = 0; i < stats.publishers.size(); i++) {
- this.publishers.get(i).add(stats.publishers.get(i));
- }
+ if (index == this.publishers.size()) {
+ PublisherStatsImpl newStats = new PublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.publishers.add(newStats);
}
+ this.publishers.get(index)
+ .add((PublisherStatsImpl) s);
Review Comment:
Hi,
I see that `*TopicStatsImpl` is not a thread-safe class. Currently, the caller needs to externally synchronize the access if concurrent threads access the same instance.
> Potentially access to it from concurrent threads.
Could you provide this example? I see that `PartitionedTopicStatsImpl` is instantiated by a single thread, and `add(..) ` gets called from the same thread.
```
PartitionedTopicStatsImpl stats = new PartitionedTopicStatsImpl(partitionMetadata);
...
FutureUtil.waitForAll(topicStatsFutureList).handle((result, exception) -> {
...
stats.add(statFuture.get());
if (perPartition) {
stats.getPartitions().put(topicName.getPartition(i).toString(), statFuture.get());
...
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] heesung-sn commented on pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
heesung-sn commented on PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#issuecomment-1366980368
@eolivelli could you review this PR by any chance?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui commented on a diff in pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#discussion_r1059248729
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/NonPersistentTopicStatsImpl.java:
##########
@@ -165,20 +166,15 @@ public NonPersistentTopicStatsImpl add(NonPersistentTopicStats ts) {
return newStats;
})).add((NonPersistentPublisherStatsImpl) s);
} else {
- if (this.nonPersistentPublishers.size() != stats.getNonPersistentPublishers().size()) {
- for (int i = 0; i < stats.getNonPersistentPublishers().size(); i++) {
- NonPersistentPublisherStatsImpl newStats = new NonPersistentPublisherStatsImpl();
- newStats.setSupportsPartialProducer(false);
- this.nonPersistentPublishers.add(newStats.add((NonPersistentPublisherStatsImpl) s));
- }
- } else {
- for (int i = 0; i < stats.getNonPersistentPublishers().size(); i++) {
- ((NonPersistentPublisherStatsImpl) this.nonPersistentPublishers.get(i))
- .add((NonPersistentPublisherStatsImpl) s);
- }
+ if (index == this.nonPersistentPublishers.size()) {
+ NonPersistentPublisherStatsImpl newStats = new NonPersistentPublisherStatsImpl();
+ newStats.setSupportsPartialProducer(false);
+ this.nonPersistentPublishers.add(newStats);
Review Comment:
It's better to add some description for this `if` branch. Like why we need to use a newStats if `index == this.nonPersistentPublishers.size()`. And what does `index == this.nonPersistentPublishers.size()` exactly means. Frankly, it's not easy to understand. I think if we have some description, it will help the readers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui merged pull request #18807: [fix][monitor] Fix the partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
codelipenghui merged PR #18807:
URL: https://github.com/apache/pulsar/pull/18807
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codecov-commenter commented on pull request #18807: [fix][monitor] Fix a partitioned publisher topic stat aggregation bug
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #18807:
URL: https://github.com/apache/pulsar/pull/18807#issuecomment-1345434268
# [Codecov](https://codecov.io/gh/apache/pulsar/pull/18807?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#18807](https://codecov.io/gh/apache/pulsar/pull/18807?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7be4cdd) into [master](https://codecov.io/gh/apache/pulsar/commit/58ad3d09ddca46e9e2805e9c7a37c0de1a5c302d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (58ad3d0) will **decrease** coverage by `10.59%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/pulsar/pull/18807?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #18807 +/- ##
=============================================
- Coverage 47.67% 37.08% -10.60%
+ Complexity 9333 1970 -7363
=============================================
Files 618 209 -409
Lines 58586 14425 -44161
Branches 6098 1574 -4524
=============================================
- Hits 27933 5350 -22583
+ Misses 27623 8489 -19134
+ Partials 3030 586 -2444
```
| Flag | Coverage Δ | |
|---|---|---|
| unittests | `37.08% <ø> (-10.60%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/18807?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...he/pulsar/client/impl/MultiTopicsConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL011bHRpVG9waWNzQ29uc3VtZXJJbXBsLmphdmE=) | `22.86% <0.00%> (-0.12%)` | :arrow_down: |
| [...naming/RangeEquallyDivideBundleSplitAlgorithm.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NvbW1vbi9uYW1pbmcvUmFuZ2VFcXVhbGx5RGl2aWRlQnVuZGxlU3BsaXRBbGdvcml0aG0uamF2YQ==) | | |
| [...er/systopic/NamespaceEventsSystemTopicFactory.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zeXN0b3BpYy9OYW1lc3BhY2VFdmVudHNTeXN0ZW1Ub3BpY0ZhY3RvcnkuamF2YQ==) | | |
| [...ion/pendingack/TransactionPendingAckException.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci90cmFuc2FjdGlvbi9leGNlcHRpb24vcGVuZGluZ2Fjay9UcmFuc2FjdGlvblBlbmRpbmdBY2tFeGNlcHRpb24uamF2YQ==) | | |
| [.../pulsar/broker/service/persistent/SystemTopic.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3BlcnNpc3RlbnQvU3lzdGVtVG9waWMuamF2YQ==) | | |
| [.../main/java/org/apache/pulsar/utils/CmdUtility.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL3V0aWxzL0NtZFV0aWxpdHkuamF2YQ==) | | |
| [...pache/pulsar/broker/admin/impl/NamespacesBase.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL05hbWVzcGFjZXNCYXNlLmphdmE=) | | |
| [...ourcegroup/ResourceUsageTopicTransportManager.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9yZXNvdXJjZWdyb3VwL1Jlc291cmNlVXNhZ2VUb3BpY1RyYW5zcG9ydE1hbmFnZXIuamF2YQ==) | | |
| [.../java/org/apache/pulsar/broker/web/WebService.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci93ZWIvV2ViU2VydmljZS5qYXZh) | | |
| [...che/pulsar/broker/resourcegroup/ResourceGroup.java](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9yZXNvdXJjZWdyb3VwL1Jlc291cmNlR3JvdXAuamF2YQ==) | | |
| ... and [402 more](https://codecov.io/gh/apache/pulsar/pull/18807/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org