Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][client] Fix deserialized BatchMessageIdImpl acknowledgment failure #15

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

BewareMyPower
Copy link
Owner

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.

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.
@BewareMyPower BewareMyPower force-pushed the bewaremypower/message-id-deserialization-fix branch from ba52f1e to 1eb278d Compare December 23, 2022 03:18
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Deserialized BatchMessageIdImpl cannot be used for acknowledgment
1 participant