Skip to content

Conversation

BewareMyPower
Copy link
Contributor

@BewareMyPower BewareMyPower commented Jul 15, 2025

Main Issue: #24497

P.S. I've found some other issues of #24497, so I will open more PRs for that.

Motivation

If any exception is thrown by managed cursor's API or the callback, MessageDeduplication#checkStatus will never have a chance to complete, which will make the PersistentTopic never available unless unloading the namespace or topic.

Modifications

  • Add ManagedLedgerUtils, which includes a set of future-based managed ledger APIs, which don't need explicit exception catching for callback-based APIs.
  • Add a ManagedLedgerReplayTask to perform replay on a managed ledger from a given position. It can handle any unexpected exception from the managed ledger APIs or callbacks.
  • Leverage ManagedLedgerReplayTask in MessageDeduplication for recovery and ManagedLedgerUtils for safe snapshot taking. These two classes can be applied in some other places for safety as well, but it's beyond the scope of this PR.

Verifying this change

  • Add ManagedLedgerReplayTaskTest to verify ManagedLedgerReplayTask works in many cases.
  • Add checkStatusFail to verify MessageDeduplication#checkStatus will complete exceptionally for unexpected exception.

Documentation

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

Matching PR in forked repository

PR in forked repository: BewareMyPower#49

@BewareMyPower BewareMyPower self-assigned this Jul 15, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jul 15, 2025
@BewareMyPower BewareMyPower added release/3.0.13 release/4.0.6 release/3.3.8 type/bug The PR fixed a bug or issue reported a bug labels Jul 15, 2025
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 92.78351% with 7 lines in your changes missing coverage. Please review.

Project coverage is 74.32%. Comparing base (bbc6224) to head (68b21b0).
Report is 1223 commits behind head on master.

Files with missing lines Patch % Lines
...he/bookkeeper/mledger/util/ManagedLedgerUtils.java 77.27% 5 Missing ⚠️
...roker/service/persistent/MessageDeduplication.java 96.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24511      +/-   ##
============================================
+ Coverage     73.57%   74.32%   +0.75%     
- Complexity    32624    32970     +346     
============================================
  Files          1877     1876       -1     
  Lines        139502   146270    +6768     
  Branches      15299    16773    +1474     
============================================
+ Hits         102638   108722    +6084     
- Misses        28908    28921      +13     
- Partials       7956     8627     +671     
Flag Coverage Δ
inttests 26.76% <2.06%> (+2.18%) ⬆️
systests 23.30% <2.06%> (-1.02%) ⬇️
unittests 73.81% <92.78%> (+0.96%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...he/bookkeeper/mledger/ManagedLedgerReplayTask.java 100.00% <100.00%> (ø)
...roker/service/persistent/MessageDeduplication.java 79.59% <96.00%> (-1.32%) ⬇️
...he/bookkeeper/mledger/util/ManagedLedgerUtils.java 77.27% <77.27%> (ø)

... and 1109 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.

@BewareMyPower BewareMyPower merged commit d95cf3f into apache:master Jul 25, 2025
51 checks passed
lhotari pushed a commit that referenced this pull request Jul 25, 2025
lhotari pushed a commit that referenced this pull request Jul 25, 2025
lhotari pushed a commit that referenced this pull request Jul 25, 2025
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Jul 28, 2025
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Jul 28, 2025
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 28, 2025
…tions (apache#24511)

(cherry picked from commit d95cf3f)
(cherry picked from commit 0444514)
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 28, 2025
…tions (apache#24511)

(cherry picked from commit d95cf3f)
(cherry picked from commit 0c1ccb8)
@BewareMyPower BewareMyPower deleted the bewaremypower/add-ml-replay-task branch July 29, 2025 07:48
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 29, 2025
…tions (apache#24511)

(cherry picked from commit d95cf3f)
(cherry picked from commit 0c1ccb8)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 30, 2025
…tions (apache#24511)

(cherry picked from commit d95cf3f)
(cherry picked from commit 0c1ccb8)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 31, 2025
…tions (apache#24511)

(cherry picked from commit d95cf3f)
(cherry picked from commit 0444514)
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants