You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lhotari (via GitHub)" <gi...@apache.org> on 2025/07/16 18:20:31 UTC
[PR] [fix][client] Fix issue in auto releasing of idle connection with topics pattern consumer [pulsar]
lhotari opened a new pull request, #24528:
URL: https://github.com/apache/pulsar/pull/24528
### Motivation
["PIP-165 Auto release client useless connections"](https://github.com/apache/pulsar/issues/15516) added a solution that closes unused idling connections. The idle check doesn't consider topic watchers created by a topics pattern (regex) consumer. The impact of this is that connections would get frequently closed and immediately reconnected when topics pattern consumers are used and when the topic watcher is the only resource using the connection.
While reviewing the code, another possible race condition was observed in the solution due lack of usage of volatile for ClientCnxIdleState's idleMarkTime field. The field gets mutated and read in different threads in certain cases.
There was also a concern that a currently used connection could get released under a race condition. That's why this PR adds another check before the ClientCnxIdleState can move from IDLE to RELEASING.
### Modifications
- fix the ClientCnx idleCheck method
- check topic list watchers
- make ClientCnxIdleState's idleMarkTime field volatile
- add extra idleCheck in ClientCnxIdleState's doIdleDetect before the state can change from IDLE to RELEASING, switch to USING if the connection is getting used.
- adds test coverage at different levels. There are also tests for the usage of Pulsar Proxy + multiple brokers.
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `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 -->
--
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][client] Fix issue in auto releasing of idle connection with topics pattern consumer [pulsar]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24528:
URL: https://github.com/apache/pulsar/pull/24528#issuecomment-3080142105
## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/24528?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `80.00000%` with `1 line` in your changes missing coverage. Please review.
> Project coverage is 74.31%. Comparing base [(`bbc6224`)](https://app.codecov.io/gh/apache/pulsar/commit/bbc62245c5ddba1de4b1e7cee4ab49334bc36277?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`2a4d454`)](https://app.codecov.io/gh/apache/pulsar/commit/2a4d4549d9a9ba9d447b8dbfbb8c731b694b6db1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 1197 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pulsar/pull/24528?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../apache/pulsar/client/impl/ClientCnxIdleState.java](https://app.codecov.io/gh/apache/pulsar/pull/24528?src=pr&el=tree&filepath=pulsar-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fclient%2Fimpl%2FClientCnxIdleState.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NsaWVudENueElkbGVTdGF0ZS5qYXZh) | 66.66% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/pulsar/pull/24528?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/24528?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #24528 +/- ##
============================================
+ Coverage 73.57% 74.31% +0.74%
- Complexity 32624 32872 +248
============================================
Files 1877 1868 -9
Lines 139502 145946 +6444
Branches 15299 16737 +1438
============================================
+ Hits 102638 108465 +5827
+ Misses 28908 28866 -42
- Partials 7956 8615 +659
```
| [Flag](https://app.codecov.io/gh/apache/pulsar/pull/24528/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/24528/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.72% <0.00%> (+2.14%)` | :arrow_up: |
| [systests](https://app.codecov.io/gh/apache/pulsar/pull/24528/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `23.33% <0.00%> (-0.99%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/pulsar/pull/24528/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.80% <80.00%> (+0.95%)` | :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/24528?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [.../java/org/apache/pulsar/client/impl/ClientCnx.java](https://app.codecov.io/gh/apache/pulsar/pull/24528?src=pr&el=tree&filepath=pulsar-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fclient%2Fimpl%2FClientCnx.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NsaWVudENueC5qYXZh) | `69.55% <100.00%> (-2.22%)` | :arrow_down: |
| [.../apache/pulsar/client/impl/ClientCnxIdleState.java](https://app.codecov.io/gh/apache/pulsar/pull/24528?src=pr&el=tree&filepath=pulsar-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpulsar%2Fclient%2Fimpl%2FClientCnxIdleState.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0NsaWVudENueElkbGVTdGF0ZS5qYXZh) | `68.75% <66.66%> (-2.37%)` | :arrow_down: |
... and [1096 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/24528/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][client] Fix issue in auto releasing of idle connection with topics pattern consumer [pulsar]
Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari merged PR #24528:
URL: https://github.com/apache/pulsar/pull/24528
--
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