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 — [fix][client] Don't return pre-redeliver messages from a multi-topics consumer's receive() by merlimat · Pull Request #27301 · apache/pulsar Conversation
Contributor
Fixes #25204 Replaces #27091, which can't be merged: GitHub counts a review thread from an account that no longer exists as unresolved, but hides it, so nobody can resolve it. codelipenghui approved #27091 at this same head commit, 8384e65. Problem
This affects multi-topic and partitioned-topic consumers. ExampleConsumer<String> consumer = client.newConsumer(Schema.STRING) .topic(partitionedTopic) .subscriptionName("sub") .subscriptionType(SubscriptionType.Failover) .subscribe(); // messages are already queued in the consumer consumer.redeliverUnacknowledgedMessages(); Message<String> msg = consumer.receive(); // can return a queued epoch-0 message // before public void redeliverUnacknowledgedMessages() { internalPinnedExecutor.execute(() -> { ... CONSUMER_EPOCH.incrementAndGet(this); ... clearIncomingMessages(); }); } protected Message<T> internalReceive() { ... message = incomingMessages.take(); // no epoch check Change
CONSUMER_EPOCH.incrementAndGet(this); internalPinnedExecutor.execute(() -> { ... }); do { message = incomingMessages.take(); decreaseIncomingMessageSize(message); checkState(message instanceof TopicMessageImpl); } while (!isValidConsumerEpoch((TopicMessageImpl<T>) message)); Two alternatives were rejected:
Testing
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions… consumer's receive() MultiTopicsConsumerImpl.redeliverUnacknowledgedMessages() bumped the consumer epoch and cleared incomingMessages in a task on the internal pinned executor, and returned before it ran. A synchronous receive() right after the call took messages that were still queued, which for Exclusive/Failover subscriptions the broker then delivers again. Bump the epoch before returning, and have the synchronous receive paths drop queued messages from an older epoch, as the pending clear would. Fixes apache#25204 The listener drain takes messages through the timed internalReceive(). When a listener requested a redelivery during a drain, the epoch bump made the drain drop the remaining queued messages without giving back their permits, which callMessageListener() does for a listener's messages. Repeated redeliveries could exhaust the permits and stall the consumer. Leave a listener's messages to callMessageListener(), which gives back the permit before it drops the messages from an older epoch. receiveMessageFromConsumer() checks the multi-topics consumer's epoch. Since the epoch is now bumped before the redeliver task runs, it also drops the old-epoch messages that the task's queue clear used to drop. For each of them it gave back a permit, which only a listener's messages still hold. Without a listener, the sub consumer already gave it back in messageProcessed() when it handed the message over, so the broker got an extra permit. Hand-overs that ran after the redeliver task already did this before. Give back the permit there only when the consumer has a listener.
codelipenghui
approved these changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewed The immediate epoch update and synchronous receive filtering address the race while preserving executor-ordered cleanup and listener permit accounting. Validation: 3 focused client test cases and all 16 Remaining coverage gap: the stale-message filtering branch in blocking
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
merlimat
added a commit
to merlimat/pulsar
that referenced
this pull request
…-selective-seek Conflicts with apache#27278 and apache#27301: - receiveMessageFromConsumer(): keep the seekingTopics check under the @VisibleForTesting signature that both sides add. - discardIncomingMessage() from apache#27278 skipped the permit give-back during any seek, since afterSeek() refilled every consumer. Now it skips it only for a consumer that is seeking, the only kind that afterSeek() refills. - testSelectiveSeekGivesBackPermitsOfSkippedPartitionOnce from apache#27278 expected the skipped partition's message to be dropped and its consumer refilled. It becomes testSelectiveSeekGivesBackPermitsOfDroppedMessageOnce: the sought partition's message is dropped and its consumer refilled once, and the skipped partition's message stays queued with its permit. - The partition consumer mocks of two tests from apache#27278 and apache#27301 now have a topic, which the seek state looks up.
ascentstream-bot
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
… consumer's receive() (apache#27301) (cherry picked from commit ea2ad82)
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
… consumer's receive() (apache#27301) (cherry picked from commit ea2ad82)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsDevelopmentSuccessfully merging this pull request may close these issues. [Bug] MultiTopicsConsumer still received message with older ConsumerEpoch after redeliverUnacknowledgeMessages()Uh oh!
There was an error while loading. Please reload this page. 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. |