-
Notifications
You must be signed in to change notification settings - Fork 337
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
feat: introduce ack trackers to prevent batch message loss #1277
base: master
Are you sure you want to change the base?
feat: introduce ack trackers to prevent batch message loss #1277
Conversation
71abd2e
to
4400dcd
Compare
Good work! I think we should fix this issue in the When acknowledging a batch message, ensure that the ledger ID, entry ID, and tracker are properly managed within a map. The logic for handling the tracker is as follows:
What do you think? |
Hello! However, if we record the batch index here, it means that adding a message does not necessarily mean it can be acknowledged, which might be a bit strange. Or perhaps we need to move this part: if trackingID != nil && trackingID.ack() {
// All messages in the same batch have been acknowledged, we only need to acknowledge the
// MessageID that represents the entry that stores the whole batch
trackingID = &trackingMessageID{
messageID: &messageID{
ledgerID: trackingID.ledgerID,
entryID: trackingID.entryID,
},
}
pc.metrics.AcksCounter.Inc()
pc.metrics.ProcessingTime.Observe(float64(time.Now().UnixNano()-trackingID.receivedTime.UnixNano()) / 1.0e9)
} to |
You can create a map to record the batch message, such as
Only record the ledger ID and entry ID.
Sounds good! |
Sounds good! |
Motivation
In the current implementation of messageID.Serialize(), the ackTracker information is not recorded. This causes an issue when the client uses DeserializeMessageID to restore the message ID. The Pulsar consumer will mistakenly acknowledge the message within the batch, causing other unacknowledged messages in the batch to be acknowledged as well. This results in message loss for the client.
Modifications
In the current consumer implementation, maintain the ackTrackers structure. When a trackingMessageID lacks an ackTracker, attempt to retrieve it from ackTrackers. Only remove the corresponding ackTracker from ackTrackers after all messages in the batch have been acknowledged.