Repository navigation
[fix][client] Fix deserialized BatchMessageIdImpl acknowledgment failure - #19031
BewareMyPower wants to merge 8 commits into
Conversation
329e6ac to
ba52f1e
Compare
|
More explanations to the refactoring parts of this PR:
|
Fixes apache#19030 ### Motivation When a `BatchMessageIdImpl` is created from a deserialization, the `BatchMessageAcker` object cannot be shared by all instances in the same batch, which leads to an acknowledgment failure when batch index ACK is disabled (by default). ### Modifications Maintain a map from the `(ledger id, entry id)` pair to the `BatchMessageAcker` in `ConsumerImpl`. If the `BatchMessageIdImpl` doesn't carry a valid `BatchMessageAcker`, create and cache a `BatchMessageAcker` instance and remove it when all messages in the batch are acknowledged. It requires a change in `MessageIdImpl#fromByteArray` that a `BatchMessageAckerDisabled` will be created to indicate there is no shared acker. To avoid making code more complicated, this patch refactors the existing code that many logics about consumer are moved from the ACK tracker to the consumer. It also removes the `AckType` parameter when acknowledging a list of messages.
ba52f1e to
1eb278d
Compare
|
Thanks for your reviews, I'm going to address the comments soon. |
|
@congbobo184 You comments are addressed now, PTAL again. |
|
|
||
|
|
||
| private CompletableFuture<Void> doIndividualAckAsync(MessageIdImpl messageId) { | ||
| private void doIndividualAckAsync(MessageIdImpl messageId) { |
There was a problem hiding this comment.
How can an Async variant be void? Especially doIndividualBatchAck below returns CompletableFuture<Void>.
There was a problem hiding this comment.
The current names of these two "Async" methods are confusing. I will rename them.
There was a problem hiding this comment.
Since this PR already includes some refactorings, I might do that in a following PR.
### Motivation Currently the main branch is broken by the concurrent merge of apache#153 and apache#151. It's because when a batched message id is constructed from deserialization, there is no `getBitSet` implementation of the internal acker. ### Modifications Add a `bool` parameter to `MessageIdImpl::getBitSet` to indicate whether the message ID is batched. The logic is similar with https://github.com/apache/pulsar/blob/299bd70fdfa023768e94a8ee4347d39337b6cbd4/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L325-L327 and https://github.com/apache/pulsar/blob/299bd70fdfa023768e94a8ee4347d39337b6cbd4/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L345-L347 Add a `testMessageIdFromBuild` to test the acknowledgment for a message ID without an acker could succeed for a consumer that enables batch index ACK. ### TODO In future, apache/pulsar#19031 might be migrated into the C++ client to fix the consumer that disables batch index ACK.
|
The pr had no activity for 30 days, mark with Stale label. |
|
As discussed on the mailing list https://lists.apache.org/thread/w4jzk27qhtosgsz7l9bmhf1t7o9mxjhp, there is no plan to release 2.9.6, so I am going to remove the release/2.9.6 label |
|
The pr had no activity for 30 days, mark with Stale label. |
|
Thanks @BewareMyPower, and sorry this sat so long. Since PIP-391 (#24203, 4.1.0) batch index ack is on by default on both client and broker, so a batch id from |
Fixes #19030
Motivation
When a
BatchMessageIdImplis created from a deserialization, theBatchMessageAckerobject cannot be shared by all instances in the same batch, which leads to an acknowledgment failure when batch index ACK is disabled (by default).Modifications
Maintain a map from the
(ledger id, entry id)pair to theBatchMessageAckerinConsumerImpl. If theBatchMessageIdImpldoesn't carry a validBatchMessageAcker, create and cache aBatchMessageAckerinstance and remove it when all messages in the batch are acknowledged.It requires a change in
MessageIdImpl#fromByteArraythat aBatchMessageAckerDisabledwill be created to indicate there is no shared acker.To avoid making code more complicated, this patch refactors the existing code that many logics about consumer are moved from the ACK tracker to the consumer. It also removes the
AckTypeparameter when acknowledging a list of messages.Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: BewareMyPower#15