Skip to content

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

Merged
lhotari merged 4 commits into
apache:masterfrom
Technoboy-:fix-22157
Mar 27, 2024
Merged

[fix][broker] Check cursor state before adding it to the waitingCursors#22191
lhotari merged 4 commits into
apache:masterfrom
Technoboy-:fix-22157

Conversation

@Technoboy-

Copy link
Copy Markdown
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

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

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 commented Apr 9, 2024

Copy link
Copy Markdown
Member

#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)
hanmz pushed a commit to hanmz/pulsar that referenced this pull request Feb 12, 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.

[Bug] Broker memory leak

3 participants