GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing github.com — [improve][broker] Add limits for Key_Shared Subscription look ahead in dispatching by lhotari · Pull Request #23231 · apache/pulsar Conversation
|
| if (readType == ReadType.Normal && stickyKeyHashes != null | |
| && redeliveryMessages.containsStickyKeyHashes(stickyKeyHashes)) { | |
| // If redeliveryMessages contains messages that correspond to the same hash as the messages | |
| // that the dispatcher is trying to send, do not send those messages for order guarantee | |
| return 0; | |
| } |
The "look ahead" limit introduced in this PR will add backpressure to how the dispatcher works. Eventually consumers will be slower than the dispatcher sending messages to consumers and that's why it's necessary to have the limit, also in cases where the hashes wouldn't be blocked or "allowOutOfOrderDelivery" mode is used.
There's also another related problem that this change addresses. The head of the replay queue might get blocked in the release Pulsar versions.
Lines 348 to 350 in ed14f21
| NavigableSet<Position> messagesToReplayNow = getMessagesToReplayNow(messagesToRead); | |
| NavigableSet<Position> messagesToReplayFiltered = filterOutEntriesWillBeDiscarded(messagesToReplayNow); | |
| if (!messagesToReplayFiltered.isEmpty()) { |
In this PR, the solution to this is to take as many entries that match the criteria from the replay queue. This required changing the getMessagesToReplayNow to accept a Predicate for filtering:
public NavigableSet<Position> getMessagesToReplayNow(int maxMessagesToRead, Predicate<Position> filter) { NavigableSet<Position> items = new TreeSet<>(); messagesToRedeliver.processItems(PositionFactory::create, item -> { if (filter.test(item)) { items.add(item); } return items.size() < maxMessagesToRead; }); return items; }
Configuration Properties:
keySharedLookAheadMsgInReplayThresholdPerConsumerkeySharedLookAheadMsgInReplayThresholdPerSubscriptionkeySharedLookAheadEnabledWhenRecentlyJoinedConsumersExistBroker Configuration:
broker.conf to include descriptions and default values for the new configuration properties.Key_Shared Subscription Logic:
filterOutEntriesWillBeDiscarded while preserving the previous logic of filtering.localGroupedEntries and the unused localGroupedPositions.
getMessagesToReplayNow(1) with getFirstPositionInReplay().
canReplayMessages to make the look-ahead logic more explicit. The previous solution of returning an empty set from the getMessagesToReplayNow method made it hard to understand how the look-ahead behavior is implemented.isDispatcherStuckOnReplays field to skipNextReplayToTriggerLookAhead to make the meaning of the field explicit and self-descriptive.!havePendingReplayRead status wasn't checked before starting a new read.
!havePendingPendingRead, but for Key_Shared it isn't.keyNumbers variable to remainingConsumersToFinishSending so that the meaning of the variable is explicit and self-descriptive.groupedEntries variable to entriesByConsumerForDispatching so that the meaning of the variable is explicit and self-descriptive.entriesWithSameKey variable to entriesForConsumer so that the variable is self-descriptive.maxUnackedMessages and unackedMessages. The unit is in individual messages and permits are in entries. These 2 cannot be mixed.doc doc-required doc-not-needed doc-complete
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is ready for initial review feedback. I'm looking into ways of adding tests for the key_shared look ahead limits. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
- take more messages until maximum amount of messages has been picked
- discarding entries at this point is a waste - it's unnecessary to be accurate with permits. The message sending will handle subtracting permits.
62a9fbf to
a263ad4
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Between |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm sorry @poorbarcode. Please let me explain the misunderstanding.
For me, the "request for changes" comment was "Please do not merge this PR fast, I will finish my review tomorrow" (#23231 (review)). That's why I dismissed it with "Outdated comment". I had already addressed also the other review comments you had made.
I'm sorry for that. I did request a review, but you didn't respond. You can check the timeline. The PR was in draft mode for some time, but the reason for that was that the PR was already approved and I didn't want anyone to merge it. I didn't realize that you wouldn't be reviewing it because of the draft status. The changes in this PR aren't final, if you have review feedback, it's possible also address that after the PR has been merged. Please add comments to this PR of any concerns you may have. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sure, thanks for replying this comment. ❤️ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…n dispatching (apache#23231) Co-authored-by: Matteo Merli <[email protected]> Co-authored-by: Yuri Mizushima <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[Bug] Key_Shared subscription could deliver messages late and nonContiguousDeletedMessagesRange could exceed managedLedgerMaxUnackedRangesToPersist
There was an error while loading. Please reload this page.