Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][broker] Check cursor state before adding it to the waitingCursors #22191

Merged
merged 4 commits into from
Mar 27, 2024

Conversation

Technoboy-
Copy link
Contributor

Fixes #22157

Motivation

The root cause :
There is a race condition between the consumer.close and checkForNewEntries.
When the consumer is closed, the waitingCursor may be empty.

public synchronized void removeConsumer(Consumer consumer, boolean isResetCursor) throws BrokerServiceException {
cursor.updateLastActive();
if (dispatcher != null) {
dispatcher.removeConsumer(consumer);
}
// preserve accumulative stats form removed consumer
ConsumerStatsImpl stats = consumer.getStats();
bytesOutFromRemovedConsumers.add(stats.bytesOutCounter);
msgOutFromRemovedConsumer.add(stats.msgOutCounter);
if (dispatcher != null && dispatcher.getConsumers().isEmpty()) {
deactivateCursor();
topic.getManagedLedger().removeWaitingCursor(cursor);
if (!cursor.isDurable()) {
.
Then after executing line-311, the cursor was added to waitingCursor.

Documentation

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

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good work @Technoboy-

@lhotari lhotari merged commit b702d44 into apache:master Mar 27, 2024
49 of 50 checks passed
lhotari pushed a commit that referenced this pull request Mar 27, 2024
lhotari pushed a commit that referenced this pull request Mar 27, 2024
Technoboy- added a commit to Technoboy-/pulsar that referenced this pull request Apr 1, 2024
@lhotari
Copy link
Member

lhotari commented Apr 9, 2024

#22454 should be cherry-picked too if this is cherry-picked since this PR introduced a regression #22435 which is fixed by #22454.

lhotari pushed a commit that referenced this pull request Apr 9, 2024
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 15, 2024
…ors` (apache#22191)

(cherry picked from commit b702d44)
(cherry picked from commit ba8ff27)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 17, 2024
…ors` (apache#22191)

(cherry picked from commit b702d44)
(cherry picked from commit ba8ff27)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 17, 2024
…ors` (apache#22191)

(cherry picked from commit b702d44)
(cherry picked from commit ba8ff27)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 19, 2024
…ors` (apache#22191)

(cherry picked from commit b702d44)
(cherry picked from commit ba8ff27)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 23, 2024
…ors` (apache#22191)

(cherry picked from commit b702d44)
(cherry picked from commit ba8ff27)
pgier pushed a commit to pgier/pulsar that referenced this pull request Aug 23, 2024
…ors` (apache#22191)

(cherry picked from commit b702d44)
(cherry picked from commit ba8ff27)
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.

[Bug] Broker memory leak
3 participants