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(pubsub): remove unused AckResult map #6656

Merged
merged 4 commits into from Sep 14, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 0 additions & 17 deletions pubsub/iterator.go
Expand Up @@ -96,9 +96,6 @@ type messageIterator struct {
eoMu sync.RWMutex
enableExactlyOnceDelivery bool
sendNewAckDeadline bool
// This stores pending AckResults for cleaner shutdown when sub.Receive's ctx is cancelled.
// If exactly once delivery is not enabled, this map should not be populated.
pendingAckResults map[string]*AckResult
}

// newMessageIterator starts and returns a new messageIterator.
Expand Down Expand Up @@ -144,7 +141,6 @@ func newMessageIterator(subc *vkit.SubscriberClient, subName string, po *pullOpt
pendingAcks: map[string]*AckResult{},
pendingNacks: map[string]*AckResult{},
pendingModAcks: map[string]*AckResult{},
pendingAckResults: map[string]*AckResult{},
}
it.wg.Add(1)
go it.sender()
Expand Down Expand Up @@ -198,7 +194,6 @@ func (it *messageIterator) done(ackID string, ack bool, r *AckResult, receiveTim
it.mu.Lock()
defer it.mu.Unlock()
delete(it.keepAliveDeadlines, ackID)
delete(it.pendingAckResults, ackID)
if ack {
it.pendingAcks[ackID] = r
} else {
Expand Down Expand Up @@ -261,9 +256,6 @@ func (it *messageIterator) receive(maxToPull int32) ([]*Message, error) {
maxExt := time.Now().Add(it.po.maxExtension)
ackIDs := map[string]*AckResult{}
it.mu.Lock()
it.eoMu.RLock()
enableExactlyOnceDelivery := it.enableExactlyOnceDelivery
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only bit that bears scrutiny. Will not setting this affect any other behaviors?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only for reading the field from the iterator object into a local variable. It was used for this function only.

it.eoMu.RUnlock()
for _, m := range msgs {
ackID := msgAckID(m)
addRecv(m.ID, ackID, now)
Expand All @@ -277,15 +269,6 @@ func (it *messageIterator) receive(maxToPull int32) ([]*Message, error) {
// close the channel without checking if it exists.
ackIDs[ackID] = newSuccessAckResult()
}
// If exactly once is enabled, keep track of all pending AckResults
// so we can cleanly close them all at shutdown.
if enableExactlyOnceDelivery {
ackh, ok := ipubsub.MessageAckHandler(m).(*psAckHandler)
if !ok {
it.fail(errors.New("failed to assert type as psAckHandler"))
}
it.pendingAckResults[ackID] = ackh.ackResult
}
}
deadline := it.ackDeadline()
it.mu.Unlock()
Expand Down