-
Notifications
You must be signed in to change notification settings - Fork 369
Fix SendAsync won't be timeout during producer reconnection #1356
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -907,6 +907,13 @@ func (p *partitionProducer) writeData(buffer internal.Buffer, sequenceID uint64, | |
| sequenceID: sequenceID, | ||
| sendRequests: callbacks, | ||
| }) | ||
| for _, cb := range callbacks { | ||
| if sr, ok := cb.(*sendRequest); ok { | ||
| if sr.enqueued != nil { | ||
| close(sr.enqueued) | ||
| } | ||
| } | ||
| } | ||
| p._getConn().WriteData(ctx, buffer) | ||
| } | ||
| } | ||
|
|
@@ -1312,6 +1319,7 @@ func (p *partitionProducer) internalSendAsync( | |
| flushImmediately: flushImmediately, | ||
| publishTime: time.Now(), | ||
| chunkID: -1, | ||
| enqueued: make(chan struct{}), | ||
| } | ||
|
|
||
| if err := p.prepareTransaction(sr); err != nil { | ||
|
|
@@ -1353,6 +1361,17 @@ func (p *partitionProducer) internalSendAsync( | |
| } | ||
|
|
||
| p.dataChan <- sr | ||
| select { | ||
|
Contributor
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. the
Member
Author
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. Yes. I agree. I have put a new PR #1422 which also address this issue. PTAL |
||
| case <-sr.enqueued: | ||
| case <-ctx.Done(): | ||
| err := ctx.Err() | ||
|
Contributor
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. Generally, timeout is not set to the ctx provided by application/user, may be we should update the ctx with context.WithTimeout(ctx, config.timeout)? |
||
| if errors.Is(err, context.DeadlineExceeded) { // Convert DeadlineExceeded error to ErrSendTimeout | ||
| err = ErrSendTimeout | ||
| } | ||
| sr.callbackOnce.Do(func() { | ||
| runCallback(callback, nil, msg, err) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func (p *partitionProducer) ReceivedSendReceipt(response *pb.CommandSendReceipt) { | ||
|
|
@@ -1583,6 +1602,7 @@ type sendRequest struct { | |
| chunkID int | ||
| uuid string | ||
| chunkRecorder *chunkRecorder | ||
| enqueued chan struct{} | ||
|
|
||
| // resource management | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.