GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [improve][broker] Reschedule reads with increasing backoff when no messages are dispatched by lhotari · Pull Request #23226 · apache/pulsar

Conversation

@lhotari

@lhotari lhotari commented Aug 26, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Main Issue: #23200

Motivation

There's currently a clear problem with Key_Shared that in normal operations, it causes a lot of "ack holes" which result in several problems. One of the problems is the latency issues that are explained in #23200. Another problem is that the large number of "ack holes" exceed managedLedgerMaxUnackedRangesToPersist (10000) in usual cases such as in the demonstration in #23200.

There are multiple other issues where there has been a large number of "ack holes" when Pulsar users have experienced problems. One of the previous mitigations is PIP-299: Stop dispatch messages if the individual acks will be lost in the persistent storage.. The need for PIP-299 proves that the large number of "ack holes" is a fairly common problem.

Modifications

While experimenting on #23200, it was determined that #7105 changes were related to the cause of the issue.
I also noticed that #18315 contained some impactful changes (https://github.com/apache/pulsar/pull/18315/files#diff-c48d5c94842ac8c9a0c9314b207298069f38c8dcfeda4a9886fb3bb1f77843f2). For Key_Shared subscriptions, the change in #10762 makes the case of not dispatching any messages a common case.

Based on this information, I decided to implement a solution where there would be a backoff when no messages are dispatched.

This PR contains a change that reschedules a call to readMoreEntries where the delay is exponentially increasing as long as no entries are dispatched. The backoff delay starts at 100ms and is limited to 1000ms. These values are configurable in broker.conf.

Additional context

While testing this change, I happened to notice that this change mitigates the problem in the reproducer of of #23200.

With the changes of this PR, these are the results:

2024-08-26T16:09:42,328+0300 [main] INFO  playground.TestScenarioIssueKeyShared - Done receiving. Remaining: 0 duplicates: 0 unique: 1000000
max latency difference of subsequent messages: 974 ms
max ack holes: 668
2024-08-26T16:09:42,329+0300 [main] INFO  playground.TestScenarioIssueKeyShared - Consumer consumer1 received 259642 unique messages 0 duplicates in 456 s, max latency difference of subsequent messages 763 ms
2024-08-26T16:09:42,329+0300 [main] INFO  playground.TestScenarioIssueKeyShared - Consumer consumer2 received 233963 unique messages 0 duplicates in 456 s, max latency difference of subsequent messages 974 ms
2024-08-26T16:09:42,329+0300 [main] INFO  playground.TestScenarioIssueKeyShared - Consumer consumer3 received 244279 unique messages 0 duplicates in 457 s, max latency difference of subsequent messages 898 ms
2024-08-26T16:09:42,329+0300 [main] INFO  playground.TestScenarioIssueKeyShared - Consumer consumer4 received 262116 unique messages 0 duplicates in 456 s, max latency difference of subsequent messages 657 ms

Documentation

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lhotari lhotari added type/bug The PR fixed a bug or issue reported a bug area/broker release/3.0.7 release/3.3.2 labels Aug 26, 2024
@lhotari lhotari added this to the 4.0.0 milestone Aug 26, 2024
@lhotari
lhotari requested review from RobertIndie, eolivelli, equanz, hangc0276, horizonzy, mattisonchao, merlimat, poorbarcode and zymap August 26, 2024 13:52
@lhotari lhotari self-assigned this Aug 26, 2024
@lhotari lhotari added the ready-to-test label Aug 26, 2024
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Aug 26, 2024
@lhotari lhotari mentioned this pull request Aug 27, 2024
[improve] PIP-381: Handle PositionInfo that's too large to serialize as a single entry #22799
Closed
1 of 15 tasks
dlg99
dlg99 approved these changes Aug 27, 2024
View reviewed changes

@dlg99 dlg99 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM but I think the backoff should be configurable

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .../java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

dao-jun
dao-jun approved these changes Aug 28, 2024
View reviewed changes
equanz
equanz reviewed Aug 28, 2024
View reviewed changes
Comment thread .../java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

equanz
equanz approved these changes Aug 28, 2024
View reviewed changes
lhotari added 2 commits August 29, 2024 07:49
@lhotari
[improve][broker] Reschedule reads with increasing delay when no mess…
326361e
…ages are dispatched
@lhotari
Make the back off initial delay and max delay configurable
b99479a
@lhotari
lhotari force-pushed the lh-use-backoff-delay-in-rescheduling-dispatcher-reads branch from 8068b31 to b99479a Compare August 29, 2024 09:13
lhotari added 4 commits August 29, 2024 12:52
@lhotari
Add test for verifying retry backoff delay
8434388
@lhotari
Improve test coverage so that resetting the backoff is also validated
fc95a6f
@lhotari
Disable dispatcher retry backoff by default in tests
3decf7c
@lhotari
Disable dispatcher retry backoff by default in tests
679cd16
@codecov-commenter

codecov-commenter commented Aug 29, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Project coverage is 74.53%. Comparing base (bbc6224) to head (679cd16).
Report is 1123 commits behind head on master.

Files with missing lines Patch % Lines
...sistent/PersistentDispatcherMultipleConsumers.java 92.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23226      +/-   ##
============================================
+ Coverage     73.57%   74.53%   +0.96%     
+ Complexity    32624     2755   -29869     
============================================
  Files          1877     1924      +47     
  Lines        139502   144915    +5413     
  Branches      15299    15845     +546     
============================================
+ Hits         102638   108016    +5378     
+ Misses        28908    28637     -271     
- Partials       7956     8262     +306     
Flag Coverage Δ
inttests 27.94% <67.74%> (+3.36%) ⬆️
systests 24.60% <67.74%> (+0.27%) ⬆️
unittests 73.89% <93.54%> (+1.05%) ⬆️

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

Files with missing lines Coverage Δ
...org/apache/pulsar/broker/ServiceConfiguration.java 98.95% <100.00%> (-0.44%) ⬇️
...ersistentStickyKeyDispatcherMultipleConsumers.java 87.65% <100.00%> (+2.01%) ⬆️
...sistent/PersistentDispatcherMultipleConsumers.java 74.48% <92.00%> (+0.15%) ⬆️

... and 547 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari
lhotari merged commit d98e51f into apache:master Aug 29, 2024
grssam pushed a commit to grssam/pulsar that referenced this pull request Sep 4, 2024
@lhotari @grssam
[improve][broker] Reschedule reads with increasing backoff when no me…
6a892d7
…ssages are dispatched (apache#23226)
lhotari added a commit that referenced this pull request Sep 5, 2024
@lhotari
[improve][broker] Reschedule reads with increasing backoff when no me…
f990e28
…ssages are dispatched (#23226)

(cherry picked from commit d98e51f)
@lhotari lhotari added the cherry-picked/branch-3.0 label Sep 5, 2024
lhotari added a commit that referenced this pull request Sep 5, 2024
@lhotari
[improve][broker] Reschedule reads with increasing backoff when no me…
8f822e6
…ssages are dispatched (#23226)

(cherry picked from commit d98e51f)
@lhotari lhotari added the cherry-picked/branch-3.3 label Sep 5, 2024
@lhotari lhotari mentioned this pull request Sep 7, 2024
[Bug] key-SHARED subscription is not performing redelivery and going in infinite while loop of reading messages from disk and not dispatching any messages #21656
Closed
2 tasks done
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 10, 2024
@lhotari @nikhil-ctds
[improve][broker] Reschedule reads with increasing backoff when no me…
cc06c3c
…ssages are dispatched (apache#23226)

(cherry picked from commit d98e51f)
(cherry picked from commit f990e28)
@lhotari lhotari mentioned this pull request Sep 11, 2024
[fix][broker] Fix retry backoff for PersistentDispatcherMultipleConsumers #23284
Merged
1 of 4 tasks
@lhotari

lhotari commented Sep 11, 2024

Copy link
Copy Markdown
Member Author

This introduces a regression that is fixed by #23284

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 12, 2024
@lhotari @srinath-ctds
[improve][broker] Reschedule reads with increasing backoff when no me…
5ae6d6a
…ssages are dispatched (apache#23226)

(cherry picked from commit d98e51f)
(cherry picked from commit f990e28)
@poorbarcode poorbarcode mentioned this pull request Sep 23, 2024
[fix] Key_Shared mode consumption latency when low traffic #23340
Merged
1 of 4 tasks
@lhotari lhotari mentioned this pull request Sep 24, 2024
[fix][broker] Avoid introducing delay when there are delayed messages or marker messages #23343
Merged
1 of 4 tasks
lhotari added a commit that referenced this pull request Sep 24, 2024
@lhotari
Revert "[improve][broker] Reschedule reads with increasing backoff wh…
c80a9a4
…en no messages are dispatched (#23226)"

This reverts commit 8f822e6.
lhotari added a commit that referenced this pull request Sep 24, 2024
@lhotari
Revert "[improve][broker] Reschedule reads with increasing backoff wh…
0fd9f17
…en no messages are dispatched (#23226)"

This reverts commit f990e28.
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 26, 2024
@lhotari @nikhil-ctds
Revert "[improve][broker] Reschedule reads with increasing backoff wh…
2a8ddfc
…en no messages are dispatched (apache#23226)"

This reverts commit f990e28.

(cherry picked from commit 0fd9f17)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Sep 26, 2024
@lhotari @srinath-ctds
Revert "[improve][broker] Reschedule reads with increasing backoff wh…
4fa2584
…en no messages are dispatched (apache#23226)"

This reverts commit f990e28.

(cherry picked from commit 0fd9f17)
hanmz pushed a commit to hanmz/pulsar that referenced this pull request Feb 12, 2025
@lhotari hanmz
[improve][broker] Reschedule reads with increasing backoff when no me…
8c17540
…ssages are dispatched (apache#23226)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@dlg99 dlg99 dlg99 approved these changes
@equanz equanz equanz approved these changes
@dao-jun dao-jun dao-jun approved these changes
@merlimat merlimat Awaiting requested review from merlimat
@hangc0276 hangc0276 Awaiting requested review from hangc0276
@eolivelli eolivelli Awaiting requested review from eolivelli
@RobertIndie RobertIndie Awaiting requested review from RobertIndie
@horizonzy horizonzy Awaiting requested review from horizonzy
@zymap zymap Awaiting requested review from zymap
@poorbarcode poorbarcode Awaiting requested review from poorbarcode
@mattisonchao mattisonchao Awaiting requested review from mattisonchao

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@lhotari lhotari

Labels

area/broker cherry-picked/branch-3.0 cherry-picked/branch-3.3 doc-not-needed Your PR changes do not impact docs ready-to-test release/3.0.7 release/3.3.2 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Milestone

4.0.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@lhotari @codecov-commenter @dlg99 @equanz @dao-jun
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.