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

[Issue 335]Fix producer state by reconnecting when receiving unexpected receipts… #336

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pulsar/producer_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,21 @@ func (p *partitionProducer) ReceivedSendReceipt(response *pb.CommandSendReceipt)
pi, ok := p.pendingQueue.Peek().(*pendingItem)

if !ok {
p.log.Warnf("Received ack for %v although the pending queue is empty", response.GetMessageId())
// if we receive a receipt although the pending queue is empty, the state of the broker and the producer differs.
// At that point, it is better to close the connection to the broker to reconnect to a broker hopping it solves
// the state discrepancy.
p.log.Warnf("Received ack for %v although the pending queue is empty, closing connection", response.GetMessageId())
p.cnx.Close()
return
}

if pi.sequenceID != response.GetSequenceId() {
p.log.Warnf("Received ack for %v on sequenceId %v - expected: %v", response.GetMessageId(),
// if we receive a receipt that is not the one expected, the state of the broker and the producer differs.
// At that point, it is better to close the connection to the broker to reconnect to a broker hopping it solves
// the state discrepancy.
p.log.Warnf("Received ack for %v on sequenceId %v - expected: %v, closing connection", response.GetMessageId(),
response.GetSequenceId(), pi.sequenceID)
p.cnx.Close()
return
}

Expand Down