Skip to content

[fix][test] Whitelist SharedPulsarCluster threads in thread leak detector#25375

Merged
lhotari merged 4 commits intoapache:masterfrom
merlimat:fix/whitelist-shared-cluster-threads
Mar 21, 2026
Merged

[fix][test] Whitelist SharedPulsarCluster threads in thread leak detector#25375
lhotari merged 4 commits intoapache:masterfrom
merlimat:fix/whitelist-shared-cluster-threads

Conversation

@merlimat
Copy link
Copy Markdown
Contributor

Summary

  • The SharedPulsarCluster is a JVM-wide singleton (shut down via shutdown hook), so its ~90-100 broker/BK/client threads are not real leaks
  • The first SharedPulsarBaseTest subclass that triggers lazy initialization was being blamed for all those threads by the thread leak detector
  • Add ThreadLeakDetectorListener.resetCapturedThreads() to allow re-capturing the thread baseline after shared infrastructure is initialized
  • Call it from SharedPulsarCluster.start() so the shared cluster threads become part of the baseline

This eliminates false-positive thread leak warnings from 16 test classes that extend SharedPulsarBaseTest.

Documentation

  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

none

Documentation Checklist

  • This PR does not require documentation changes

Note

Ready to test

Labels: area/test

…ctor

The SharedPulsarCluster is a JVM-wide singleton shut down via shutdown
hook, so its threads are not real leaks. The first SharedPulsarBaseTest
subclass that triggers lazy initialization was being blamed for ~90-100
broker/BK/client threads.

Add ThreadLeakDetectorListener.resetCapturedThreads() to re-capture the
thread baseline after shared infrastructure is initialized. Call it from
SharedPulsarCluster.start() so the shared cluster threads become part of
the baseline before any test class is evaluated.
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 20, 2026
…eeper

- ManagedLedgerTest: Add @cleanup("shutdown") to two ManagedLedgerFactoryImpl
  local variables in testNonDurableCursorCreateForInactiveLedger and
  testNoOrphanScheduledTasksAfterCloseML that were never shut down, leaking
  OrderedScheduler and cache eviction threads
- PulsarMockBookKeeper: Use shutdownNow() instead of shutdown() for the
  scheduler so the mock BK thread terminates immediately on cleanup
Add explicit type witness to Collectors.toCollection() to fix
generic type inference failure with Collections.unmodifiableSet().
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.74%. Comparing base (a3ae705) to head (6b40dbe).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #25375      +/-   ##
============================================
+ Coverage     72.52%   72.74%   +0.21%     
+ Complexity    34275    34255      -20     
============================================
  Files          1927     1954      +27     
  Lines        154339   154791     +452     
  Branches      17683    17730      +47     
============================================
+ Hits         111935   112600     +665     
+ Misses        33389    33161     -228     
- Partials       9015     9030      +15     
Flag Coverage Δ
inttests 25.78% <ø> (-0.25%) ⬇️
systests 22.49% <ø> (?)
unittests 73.73% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 172 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lhotari lhotari merged commit 7a919db into apache:master Mar 21, 2026
54 checks passed
@lhotari lhotari added this to the 4.2.0 milestone Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/test doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants