You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "merlimat (via GitHub)" <gi...@apache.org> on 2026/03/18 22:05:31 UTC
[PR] [fix][test] Fix flaky TopicListSizeResultCacheTest concurrent requests test [pulsar]
merlimat opened a new pull request, #25357:
URL: https://github.com/apache/pulsar/pull/25357
## Flaky test failure
```
java.lang.AssertionError: expected [true] but found [false]
at org.testng.Assert.assertTrue(Assert.java:56)
at org.apache.pulsar.broker.topiclistlimit.TopicListSizeResultCacheTest.testResultHolder_concurrentRequestsWaitForFirstToComplete(TopicListSizeResultCacheTest.java:132)
```
## Summary
Fix flaky `TopicListSizeResultCacheTest.testResultHolder_concurrentRequestsWaitForFirstToComplete` which had two bugs:
1. **Unsynchronized `ArrayList`**: `futures` list was populated from multiple threads via `futures.add()` without synchronization, causing potential data corruption and lost adds.
2. **Wrong ordering assumption**: The test assumed `futures.get(0)` was the "first" request (the one that wins the CAS in `getSizeAsync()` and gets back a completed future). But thread scheduling is nondeterministic — any thread could add its future to the list first regardless of which called `getSizeAsync()` first.
### Fix
- Use `CopyOnWriteArrayList` for thread-safe concurrent adds
- Instead of assuming `futures.get(0)` is the CAS winner, count how many futures are done (should be exactly 1) and find it via `stream().filter(isDone)`
- Verify all futures complete after `updateSize()` without assuming index-based ordering
Verified with `invocationCount = 100` — 100/100 pass.
## Documentation
- [x] `doc-not-needed`
(Your PR doesn't need any doc update)
## Matching PR in forked repository
_No response_
### Tip
Add the labels `ready-to-test` and `area/test` to trigger the CI.
--
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
Re: [PR] [fix][test] Fix flaky TopicListSizeResultCacheTest concurrent requests test [pulsar]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #25357:
URL: https://github.com/apache/pulsar/pull/25357#issuecomment-4087556191
## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/25357?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `14 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 72.72%. Comparing base ([`7f6bc23`](https://app.codecov.io/gh/apache/pulsar/commit/7f6bc233dc37d0bd981f9bfe3ccc104069ac39a4?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`be63377`](https://app.codecov.io/gh/apache/pulsar/commit/be63377cc76d9f58f4a173b0a1b01ad150d77d91?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 8 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/25357?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...r/topiclistlimit/TopicListSizeResultCacheTest.java](https://app.codecov.io/gh/apache/pulsar/pull/25357?src=pr&el=tree&filepath=pulsar-broker-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Ftopiclistlimit%2FTopicListSizeResultCacheTest.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL3Rlc3QvamF2YS9vcmcvYXBhY2hlL3B1bHNhci9icm9rZXIvdG9waWNsaXN0bGltaXQvVG9waWNMaXN0U2l6ZVJlc3VsdENhY2hlVGVzdC5qYXZh) | 0.00% | [14 Missing :warning: ](https://app.codecov.io/gh/apache/pulsar/pull/25357?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/pulsar/pull/25357?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #25357 +/- ##
=============================================
+ Coverage 37.45% 72.72% +35.26%
- Complexity 13161 34253 +21092
=============================================
Files 1897 1954 +57
Lines 150557 154770 +4213
Branches 17215 17718 +503
=============================================
+ Hits 56398 112550 +56152
+ Misses 86428 33182 -53246
- Partials 7731 9038 +1307
```
| [Flag](https://app.codecov.io/gh/apache/pulsar/pull/25357/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [inttests](https://app.codecov.io/gh/apache/pulsar/pull/25357/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `25.77% <0.00%> (-0.27%)` | :arrow_down: |
| [systests](https://app.codecov.io/gh/apache/pulsar/pull/25357/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `22.50% <0.00%> (+<0.01%)` | :arrow_up: |
| [unittests](https://app.codecov.io/gh/apache/pulsar/pull/25357/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.71% <ø> (+39.53%)` | :arrow_up: |
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=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/25357?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...r/topiclistlimit/TopicListSizeResultCacheTest.java](https://app.codecov.io/gh/apache/pulsar/pull/25357?src=pr&el=tree&filepath=pulsar-broker-common%2Fsrc%2Ftest%2Fjava%2Forg%2Fapache%2Fpulsar%2Fbroker%2Ftopiclistlimit%2FTopicListSizeResultCacheTest.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci1jb21tb24vc3JjL3Rlc3QvamF2YS9vcmcvYXBhY2hlL3B1bHNhci9icm9rZXIvdG9waWNsaXN0bGltaXQvVG9waWNMaXN0U2l6ZVJlc3VsdENhY2hlVGVzdC5qYXZh) | `0.00% <0.00%> (ø)` | |
... and [1419 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/25357/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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
Re: [PR] [fix][test] Fix flaky TopicListSizeResultCacheTest concurrent requests test [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari merged PR #25357:
URL: https://github.com/apache/pulsar/pull/25357
--
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