-
Notifications
You must be signed in to change notification settings - Fork 443
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
producer: avoid sending duplicate data #217
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,12 +342,23 @@ func (w *Producer) popTransaction(frameType int32, data []byte) { | |
} | ||
|
||
func (w *Producer) transactionCleanup() { | ||
// clean up transactions we can easily account for | ||
for _, t := range w.transactions { | ||
t.Error = ErrNotConnected | ||
t.finish() | ||
l: | ||
for { | ||
select { | ||
case data := <-w.responseChan: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we probably have the same race in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're right. The real error reason should pass to user, not just set error reason to |
||
w.popTransaction(FrameTypeResponse, data) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these be popped and finished with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the release code like below: func (w *Producer) transactionCleanup() {
l:
for {
select {
case data := <-w.responseChan:
w.popTransaction(FrameTypeResponse, data)
case data := <-w.errorChan:
w.popTransaction(FrameTypeError, data)
default:
// clean up transactions we can easily account for
for _, t := range w.transactions {
t.Error = ErrNotConnected
t.finish()
}
w.transactions = w.transactions[:0]
break l
}
}
... ...
} The transaction poped in |
||
case data := <-w.errorChan: | ||
w.popTransaction(FrameTypeError, data) | ||
default: | ||
// clean up transactions we can easily account for | ||
for _, t := range w.transactions { | ||
t.Error = ErrNotConnected | ||
t.finish() | ||
} | ||
w.transactions = w.transactions[:0] | ||
break l | ||
} | ||
} | ||
w.transactions = w.transactions[:0] | ||
|
||
// spin and free up any writes that might have raced | ||
// with the cleanup process (blocked on writing | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this label is necessary since it's not a nested
for
loop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
for
loop, there's aselect
in it, without label,break
only jump out fromselect
notfor
.