[fix][broker] Fix Broker OOM due to too many waiting cursors and reuse a recycled OpReadEntry incorrectly - #24551
Merged
Merged
Conversation
BewareMyPower
requested changes
Jul 23, 2025
lhotari
reviewed
Jul 23, 2025
BewareMyPower
approved these changes
Jul 24, 2025
Contributor
Author
|
/pulsarbot rerun-failure-checks |
gaoran10
approved these changes
Jul 24, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24551 +/- ##
============================================
+ Coverage 73.57% 74.31% +0.74%
- Complexity 32624 32967 +343
============================================
Files 1877 1874 -3
Lines 139502 146282 +6780
Branches 15299 16777 +1478
============================================
+ Hits 102638 108710 +6072
- Misses 28908 28939 +31
- Partials 7956 8633 +677
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
2 tasks
5 tasks
lhotari
added a commit
to lhotari/pulsar
that referenced
this pull request
Jul 26, 2025
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Jul 28, 2025
…e a recycled OpReadEntry incorrectly (apache#24551) (cherry picked from commit 48dc9ec)
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Jul 28, 2025
…e a recycled OpReadEntry incorrectly (apache#24551) (cherry picked from commit 48dc9ec)
priyanshu-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 28, 2025
…e a recycled OpReadEntry incorrectly (apache#24551) (cherry picked from commit 48dc9ec) (cherry picked from commit f68bf2b)
priyanshu-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 28, 2025
…e a recycled OpReadEntry incorrectly (apache#24551) (cherry picked from commit 48dc9ec) (cherry picked from commit abf511b)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 29, 2025
…e a recycled OpReadEntry incorrectly (apache#24551) (cherry picked from commit 48dc9ec) (cherry picked from commit abf511b)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 30, 2025
…e a recycled OpReadEntry incorrectly (apache#24551) (cherry picked from commit 48dc9ec) (cherry picked from commit abf511b)
srinath-ctds
pushed a commit
to datastax/pulsar
that referenced
this pull request
Jul 31, 2025
…e a recycled OpReadEntry incorrectly (apache#24551) (cherry picked from commit 48dc9ec) (cherry picked from commit f68bf2b)
KannarFr
pushed a commit
to CleverCloud/pulsar
that referenced
this pull request
Sep 22, 2025
…e a recycled OpReadEntry incorrectly (apache#24551)
walkinggo
pushed a commit
to walkinggo/pulsar
that referenced
this pull request
Oct 8, 2025
…e a recycled OpReadEntry incorrectly (apache#24551)
This was referenced Jul 8, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Background
1. Pending read if no entries to read.
managedledger.waitingCursorsif there are no entries to read.cursor.notifyEntriesAvailableonce new entries were added.2, Double-check that it has more entries.
newEntriesCheckDelayInMillisis larger than0[code-1].3. The variable waitingReadOp of cursor
OpReadEntryto trigger a new read after getting notified that new entries were added.4. The variable waitingCursors of Managed Cursor
Issue 1: The same cursor was added to
managedledger.waitingCursorsthousands of times.FailoverC1); it becomes an active consumer.C2); C2 becomes the active consumer after a choice by the dispatcherscheduleReadOnActiveConsumerscheduleReadOnActiveConsumerresets the variablecursor.waitingReadOp, but it forgets to remove the cursor frommanagedledger.waitingCursorstestWaitingCursorsCountAfterSwitchingActiveConsumersIssue 2: Reused a recycled OpReadEntry, which causes repeated delivery and other unexpected issues
OpReadEntryand set tocursor.waitingReadOpcursor.waitingReadOpOpReadEntry, which was created by the taskread entriesOpReadEntryOpReadEntryto read entries, but it has been recycled and reused by other tasksIssue 3: The method
cursor.checkForNewEntriesforgets to remove cursor frommanagedledger.waitingCursors.cursor.checkForNewEntriesimplements the double-check that checks whether there are entries to read.cursor.waitingReadOpand trigger a reading if there are entries to read after the first check.managedledger.waitingCursorsafter clearing the variablecursor.waitingReadOpModifications
3issuesmanagedledger.waitingCursorsandcursor.waitingReadOpeverywhere, Managed Cursor handles the variables itselfDocumentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: x